Hartmut Weinrebe
2005-Apr-01 18:27 UTC
[R] Error in colMeans ... what's wrong with my data?
Having searched and searched I still haven't found what's the problem with my data (I've attached the relevant file). Every time I tried to use the CANCOR-Function I got error messages. So I turned to check my two sets of variables separately by using the "colMeans"-Function. With one set no problem .. but with the other. My input :> 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? Many thanks in advance hardy -- Hartmut Weinrebe Wilhelmstr. 73 - 76137 Karlsruhe - 0721/386486 Akaflieg - hardy at akaflieg.uni-karlsruhe.de Kaiserstr. 12 - 76128 Karlsruhe - 0721/608-2044 __________________________________________________________ Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min. weltweit telefonieren! http://freephone.web.de/?mc=021201
Federico Calboli
2005-Apr-01 20:26 UTC
[R] Error in colMeans ... what's wrong with my data?
On Fri, 2005-04-01 at 20:27 +0200, Hartmut Weinrebe wrote:> Having searched and searched I still haven't found what's the problem with my data (I've attached the relevant file). > Every time I tried to use the CANCOR-Function I got error messages. > So I turned to check my two sets of variables separately by using the "colMeans"-Function. With one set no problem .. but with the other. > > My input : > > > 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 >Check what str(stuktur) gives you... looks like it seeing your numbers as something else.. BTW, I do not to have the attached file, seems to have been dropped before reaching my inbox, so that's all I can suggest. F -- Federico C. F. Calboli Department of Epidemiology and Public Health Imperial College, St Mary's Campus Norfolk Place, London W2 1PG Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 f.calboli [.a.t] imperial.ac.uk f.calboli [.a.t] gmail.com
Prof Brian Ripley
2005-Apr-02 07:21 UTC
[R] Error in colMeans ... what's wrong with my data?
On Fri, 1 Apr 2005, Hartmut Weinrebe wrote:> Having searched and searched I still haven't found what's the problem with my data (I've attached the relevant file). > Every time I tried to use the CANCOR-Function I got error messages. > So I turned to check my two sets of variables separately by using the "colMeans"-Function. With one set no problem .. but with the other. > > My input : > >> 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.) -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595