[R] two questions for R beginners
hadley wickham
h.wickham at gmail.com
Mon Mar 1 16:13:54 CET 2010
> One of the things about R which many (and that certainly includes
> me) have to find out the hard way is that you have to *learn*
> what to expect! You can't just import it from prior experience in
> other contexts. So, by the time you have learned that a matrix
> is such that all its elements must have the same type, whereas
> the components of a list (or as special case the columns of a
> dataframe) can be of different types, you expect the first result
> (your "cbind(1:2,letters[1:2])"): R can coerce the numerical
> elements to character type, but letters have too much character
> to allow themselves be coerced into numerical.
cbind is not the best example, because it has rather complex behaviour:
cbind(1:2, letters[1:2])
cbind(1:2, letters[1:2], data.frame(1:2))
cbind(cbind(1:2, letters[1:2]), data.frame(1:2))
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
More information about the R-help
mailing list