[R] help

Marc Schwartz (via MN) mschwartz at mn.rr.com
Mon Apr 17 17:46:17 CEST 2006


On Mon, 2006-04-17 at 10:17 -0400, Gong, Yanyan wrote:
> Hi, I am trying to runn a age-period-cohort model, but here is what I am
> having problem with, hope you can help me!
> 
> This is what I am trying to do:
> sumzero_a<-((A-min(A))/5+1) - mean((A-min(A))/5+1)  where A is my age
> variable (numeric, the mid-point of a five-year age group), but I got the
> following error:
> 
> Error in min(..., na.rm = na.rm) : invalid 'mode' of argument
> 
> I am pretty sure I have the variable "A" in my data, can you see why this
> happens?
> 
> Thanks.
> 
> Yanyan

'A' does exist or you should get something like the following:

> min(A)
Error in min(A) : object "A" not found


More than likely, 'A' is not a numeric vector. It could be a character
vector, a list or some other non-atomic data type.  It is not a factor,
lest you get something like the following:

Error in Summary.factor(..., na.rm = na.rm) :
        min not meaningful for factors


See ?is.atomic for some additional information.

Without your code, it would be difficult to ascertain how 'A' is
created. However, consider the following example:

> L <- LETTERS

> L
 [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q"
[18] "R" "S" "T" "U" "V" "W" "X" "Y" "Z"

> min(L)
Error in min(..., na.rm = na.rm) : invalid 'mode' of argument

> mode(L)
[1] "character"


I would use:

str(A)

or

mode(A)

to see what 'A' is. That should give you a hint.

HTH,

Marc Schwartz




More information about the R-help mailing list