[R] How avoid coercion to character
dmurdoch at pair.com
Tue Jun 15 20:11:40 CEST 2004
On Tue, 15 Jun 2004 14:45:14 -0300, Eduardo Dutra de Armas
<edarmas at carpa.ciagri.usp.br> wrote :
>I'd like to know how to avoid automatic coercion of numeric variables
>passed to array() to character, when there is one categorical variable
>between others. I have tried I() function, but it is just functional
You can't. An array is just a vector with a dimension attribute, and
vectors have to be all one type. Since in general you can't coerce
text to numbers, R coerces the numbers to text.
You probably want a data.frame if you have mixed types, or if that
doesn't have enough dimensions for you, then build things out of lists
(which is how data.frames are constructed).
More information about the R-help