[R] inconsistency with cor() - "x must be numeric"

Erik Iverson eriki at ccbr.umn.edu
Mon Dec 13 23:03:29 CET 2010


Please provide a reproducible example!

E.g., use ?dput to dump a minimal data.frame that
exhibits this issue on the newest version of R.

Justin Fincher wrote:
> Howdy,
>    I have written a small function to generate a simple plot and my
> colleague is having an error when attempting to run it.  Essentially I loop
> through categories in a data frame and take the average value for each
> category The categories are in $V1, subset first then mean taken and
> concatenated to previous values using rbind(c("label",mean(data$V6)).  The
> result is a two-column matrix with labels in column one and values in column
> two.  Within the function I calculate the correlation of column two and
> another set of values that are part of the function.  On my computer (linux
> box running R 2.8.1) the function runs correctly.  On my colleague's
> computer (Windows box running R 2.12) the function throws an error at the
> cor() function call saying that "x must be numeric."  We are running on the
> exact same data set and source'ing the same function definition.  Any help
> would be appreciated.
> 
> - Fincher
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list