[R] Odp: A matrix with mixed character and numerical columns
petr.pikal at precheza.cz
Thu May 31 13:57:18 CEST 2007
r-help-bounces at stat.math.ethz.ch napsal dne 31.05.2007 12:48:11:
> Is it possible to have one?
> I have a data.frame with two character columns and 6 numerical columns.
> I converted to a matrix as I needed to use the col() and row()
> However, if I convert the data.frame to a matrix, using as.matrix, the
> numerical columns get converted to characters, and that messes up some
> of the calculations.
> Do I really have to split it up into two matrices, one character and the
> other numerical, just so I can use the col() and row() functions? Are
> there equivalent functions for data.frames?
AFAIK I do not remember equivalent functions for data frame. If you just
want column or row index you can use
1:dim(DF) or 1:dim(DF) for rows and columns
if you want repeat these indexes row or columnwise use
matrix(rrr,dim(DF), dim(DF), byrow=T)
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help