[R] " 'x' must be numeric"

Douglas Grove dgrove at fhcrc.org
Sat Jan 21 01:43:17 CET 2006


It's much more helpful if you show the actual command you used.

Presumably you have a data frame 'd' and you've done

hist(d), and 'hist' has complained because d is not numeric,
d is a data frame that *contains* a numeric vector.

You need to give hist() that numeric vector, which you can do
in many ways, including: d$V1, d[,"V1"] and d[,1]

Doug


On Fri, 20 Jan 2006, Naiara S. Pinto wrote:

> Hello all,
> 
> I am importing data from a txt file and try to get a histogram, I get the
> message: "Error in hist: 'x' must be numeric".
> When I use mode R returns "List".
> However when I use srt I get:
> `data.frame':   456 obs. of  1 variable:
>  $ V1: num  0.6344 0.4516 0.0968 0.7634 0.7957 ...
> My file consists of one column only (no headers) and I can't figure out
> why I am getting this error message. Why does this happen?
> 
> Thanks!
> 
> Naiara.
> 
> --------------------------------------------
> Naiara S. Pinto
> Ecology, Evolution and Behavior
> 1 University Station A6700
> Austin, TX, 78712
> 
> ______________________________________________
> R-help at 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
>




More information about the R-help mailing list