【发布时间】:2014-10-19 19:02:23
【问题描述】:
我是 R 的新手——我从教授那里得到了这个文件。在格罗斯上校。你总共有 1004 个 col.s
lnr Klasse Gesch Alter Groesse Gewicht Mathe Physik Deutsch Bio Fehltage
1 6 w 12 124 42 3 NA 2 3 2
2 5 w 12 146 39 4 NA 2 2 3
3 10 w 17 174 64 4 3 5 2 4
4 8 w 15 138 53 5 6 4 3 0
5 8 w 15 147 56 5 4 3 2 3
6 9 m 16 162 65 2 2 4 2 2
7 6 w 14 141 49 2 NA 2 3 2
8 10 w 16 166 60 5 5 1 3 2
9 6 w 13 152 44 4 NA 2 2 1
10 5 w 12 151 39 5 NA 4 4 4
11 6 w 13 154 46 2 NA 2 1 4
12 5 w 12 163 41 1 NA 5 1 4
13 6 m 12 139 47 5 NA 5 4 1
14 7 w 14 145 51 4 NA 5 5 2
15 8 w 14 157 49 5 5 4 2 1
16 7 w 14 159 49 4 NA 2 3 1
17 9 w 15 149 55 1 2 3 2 3
18 6 m 13 144 49 1 NA 3 1 6
19 11 m 17 190 71 5 5 3 2 1
20 6 m 12 150 46 3 NA 2 3 6
21 9 w 17 165 65 3 6 5 1 5
22 5 w 13 151 47 2 NA 5 4 2
23 10 w 17 154 65 5 3 4 4 5
结果如下:
Daten <- read.csv(file="C:/Users/WillieEkaPutra/Documents/D.Studium/Sem3/Stati 1/Uebung/Schueler.csv")
hist(Daten$Groesse)
# Error in hist.default(Daten$Groesse) : 'x' must be numeric
hist(as.numeric(Daten$Groesse))
# Error in hist.default(as.numeric(Daten$Groesse)) :
#
# invalid number of 'breaks'
hist(as.numeric(Daten$Groesse), breaks= 1)
# Error in hist.default(as.numeric(Daten$Groesse), breaks = 1) :
# character(0)
# In addition: Warning messages:
# 1: In min(x) : no non-missing arguments to min; returning Inf
# 2: In max(x) : no non-missing arguments to max; returning -Inf
hist(as.numeric(Daten$Groesse), breaks= 1)
# Error in hist.default(as.numeric(Daten$Groesse), breaks = 1004) :
# character(0)
# In addition: Warning messages:
# 1: In min(x) : no non-missing arguments to min; returning Inf
# 2: In max(x) : no non-missing arguments to max; returning -Inf
谁知道,有什么问题吗?我会很高兴得到任何帮助。 问候, 威利
【问题讨论】:
-
class(Daten$Groesse) ; summary(Daten$Groesse)的结果是什么?您包含的示例对我来说很好,只需hist。 -
跟进@hrbrmstr 我认为使用 as.numeric() 而不考虑为什么必须这样做可能是第一个问题。不要试图仅仅解决问题,弄清楚第一个问题是什么。
-
class(Daten$Groesse) 的输出是什么?我尝试了您的代码,而 hist(Daten$Groesse) 对我来说效果很好: 最坏的情况:将您的数据复制到一个新的 excel 文件中并将其另存为 txt。然后再次执行您的代码。使用 Daten
-
@hrbmstr 好吧,它返回这个:> class (y) [1] "NULL"
-
@maRtin > Daten