I have problem to plot histogram.
What I did is:
export a .csv file from PSQL database's table.
so, inside this .csv file it looks like:
31.845
24.598
29.1223
24.715
23.1847
24.2321
25.2995
23.4261
30.7873
......
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?
Thanks a lot.
score<- read.csv('file.csv', header = FALSE,sep = ",")
type in score again to display it ... and you'll 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
so when you say plot score, R is trying to plot a variable score not
already defined ... so you just have to define it, something like this:
s <- score[,1];
hist(s,main = "score")
Hope that helps
Eric B
> 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
read.csv returns a data frame - i.e. a table. Even if it only has one
column it is still a data frame. What you want is this:
hist(score[,1])
Alternatively, you can use scan() to read the file into a vector.
cu
Philipp
--
Dr. Philipp Pagel Tel. +49-8161-71 2131
Dept. of Genome Oriented Bioinformatics Fax. +49-8161-71 2186
Technical University of Munich
http://mips.gsf.de/staff/pagel