Re: [R] histogram error: 'x' must be numeric

From: Barry Rowlingson <B.Rowlingson_at_lancaster.ac.uk>
Date: Sat 11 Feb 2006 - 00:59:25 EST

jia ding wrote:

> Then, I use command:
> score<- read.csv('file.csv', header = FALSE,sep = ",")
> hist(score, main = "score")
>
> it gives error msg:
> Error in hist.default("score", main = "score") :
> 'x' must be numeric
>
> Can any of you know about it explain me why?

  Have a look at 'score' in R first. You might get this:

 > score

        V1

1 31.8450
2 24.5980
3 29.1223
4 24.7150
5 23.1847
6 24.2321
7 25.2995
8 23.4261
9 30.7873

  hist(score$V1)

  since V1 is the name of the column.

  If your data is just one column, then you could do:

  score = scan("file.csv")

  and then

  hist(score)

  since scan() has read it into a single vector, not a data frame.

Barry



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Feb 11 01:14:19 2006

This archive was generated by hypermail 2.1.8 : Mon 13 Feb 2006 - 22:41:20 EST