[R] RE: Matrix to data.frame without factors
Mäkinen Jussi
Jussi.Makinen at valtiokonttori.fi
Fri Apr 12 11:50:46 CEST 2002
Sorry, last answer slipped away because accidental key shortcut typing.
Thank you for your reply. Here is a sample of my data.frame (KUNTADATA):
KUNTADATA[1:10,c(6:8, 20)]
Kunta Period Name Asunnot 1100 intarr_14
1 ESPOON KAUPUNKI 1993/1 14164 41336.27
2 ESPOON KAUPUNKI 1993/2 14164 NA
3 ESPOON KAUPUNKI 1994/1 14164 0.00
4 ESPOON KAUPUNKI 1994/2 14164 330.29
5 ESPOON KAUPUNKI 1995/1 14164 0.00
6 ESPOON KAUPUNKI 1995/2 14164 0.00
7 ESPOON KAUPUNKI 1996/1 14164 67277.18
8 ESPOON KAUPUNKI 1996/2 14164 7860.26
9 ESPOON KAUPUNKI 1997/1 14164 NA
10 ESPOON KAUPUNKI 1997/2 14164 231701.05
So there is both character vector and numerical vectors. But truly - I could
just use na.to.0 when neccessary with numerical rows. But because I have
face this "problem" with factors quite often I though that it might be a
common interest to ask my question.
Still I cannot understand the result:
> is.numeric(as.matrix(KUNTADATA[,15]))
[1] TRUE
> is.numeric(as.data.frame(as.matrix(KUNTADATA[,15])))
[1] FALSE
Yes, your code works nicely (as always) and do the trick I wanted, something
I couldn't write down myself. There is for me a lot to learn within R/Splus.
Thank you, I appreciated your help and this list,
Jussi Makinen
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list