簡體   English   中英

R和直方圖制作(帶中斷)

[英]R and histogram making (with breaks)

我是R的新手-我是從教授那里獲得此文件的。 在Groesse col。 您總共有1004個cols

 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

誰知道,怎么了? 我會很高興為您提供任何幫助。 問候,wili

@WillieEkaputra,您必須刪除路徑后的括號並在其中添加逗號。 像這樣:

Daten <- read.table(file="C:/Users/WillieEkaPutra/Documents/.../Schueler.txt", header=TRUE) 

如果路徑正確,這應該可以使其正常工作。

您是否會像這樣保持read.csv(file =“文件的網址”,header = T和sep =“;”) ,而不是;(分號)使用記錄的分隔符

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM