Error in colMeans ... what's wrong with my data?
Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
On Fri, 1 Apr 2005, Hartmut Weinrebe wrote:
[snip]
struktur <- read.delim("struktur.csv", header=TRUE, sep = ";")
colMeans(struktur)
And the resulting error:
Error in colMeans(x, n, prod(dn), na.rm) :
`x' must be numeric
Can anyone give me a hint concerning the mistake I made?
You applied colMeans to a data frame: the help page says
x: an array of two or more dimensions, containing numeric,
complex, integer or logical values, or a numeric data frame.
One or more columns of `struktur' are not numeric. (Note that whereas
an array can be logical, a data frame must be wholly numeric.)
I also note that read.delim() is being used on a semicolon separated CSV file. Why not read.csv2() which is designed for exactly that? A column with a decimal comma could easily explain the situation.
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907