[R] hist() and database

jcb jcb-bartier at wanadoo.fr
Mon Jan 24 20:52:42 CET 2005


Hello,

I'm a new R user and I'm having a little trouble getting started. I'm 
hoping
someone can help me out. I read numbers (integer) from a SQL database. 
Some calculations as mean()are possible but hist() give an error. Here 
are the commands:

library(RMySQL)
Loading required package: DBI
 > con <- dbConnect(dbDriver("MySQL"), dbname = "test")
 > dbListTables(con)
[1] "individu"
res <- dbSendQuery(con,"select taille from individu")
 > data <- fetch(res,-1)
 > data
   taille
1     184
2     175
3     189
4     173
5     169
6     175
7     164
8     190
9     174
10    184
11    168
12    179
13    174
14    163
15    175
16    176
17    190
18    172
19    178
20    173
 > mean(data)
taille
176.25
 > hist(data)
Error in hist.default(data) : `x' must be numeric

What can I do to draw the histogram ?

Thanks for your time

JC Bartier




More information about the R-help mailing list