Re: [R] hist() and database

2005-01-24 Thread Uwe Ligges
jcb wrote:
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
10184
11168
12179
13174
14163
15175
16176
17190
18172
19178
20173
 > mean(data)
taille
176.25
 > hist(data)
Error in hist.default(data) : `x' must be numeric
What can I do to draw the histogram ?
data is a data.frame, instead use:
  hist(data$taille)
Uwe Ligges

Thanks for your time
JC Bartier
__
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
__
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


[R] hist() and database

2005-01-24 Thread jcb
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
10184
11168
12179
13174
14163
15175
16176
17190
18172
19178
20173
> 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
__
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