[R] what is the meaning of this error

Gavin Simpson gavin.simpson at ucl.ac.uk
Thu Aug 20 15:07:07 CEST 2009

On Thu, 2009-08-20 at 12:54 +0000, Inchallah Yarab wrote:
> Error in Math.factor(c(2L, 1L, 1L, 1L, 1L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, : 
>  log not meaningful for factors
> In addition:Warning messages:
> 1: In Ops.factor(LRUpBound, LRLowBound) : * not meaningful for factors
> 2: In Ops.factor(TransitCoefStdDev, TransitCoefMean) :
>  / not meaningful for factors

Your data are stored in a factor and you can't use the log() function on
a factor.

I've mentioned this several times to you; just because you think your
data are numeric etc doesn't mean the R sees them that way. Always do


[where DAT is your data object]

after reading your data in to R and check that the stated formats are
what you think. If you have numeric data but str() reports them to be
factors, see the FAQ for how to correctly undo this conversion. One way
is to:

DAT$foo <- as.numeric(as.character(DAT$foo))

where foo is the factor you wish to convert to numeric.

And please (!!!!) read *and* follow the posting guide before sending
emails to this list. We need to  know what you did to get the error (the
error itself is not always clear without the context) so show us the
commands. And to be even more helpful, show us an example with dummy or
real data that you give to us so we can run it on our computers.

There is no free lunch (well, not often) on R-Help. Help us to help you.



> 	[[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.
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk

More information about the R-help mailing list