[R] RE: Matrix to data.frame without factors
Mäkinen Jussi
Jussi.Makinen at valtiokonttori.fi
Fri Apr 12 14:58:19 CEST 2002
Sorry, my previous answer slipped away because accidental key shortcut
typing when I was trying to copy/paste the example.
***
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 type of vectors: characterical and numerical. But truly - I
could just use na.to.0 when neccessary with numerical rows. But because I
have faced this "problem" with conversions quite often I though that it
might be a common interest to ask my question.
I still cannot understand the result:
> is.numeric(as.matrix(KUNTADATA[,15]))
[1] TRUE
> is.numeric(as.data.frame(as.matrix(KUNTADATA[,15])))
[1] FALSE
> mode(as.data.frame(as.matrix(KUNTADATA[1,15])))
[1] "list"
I'm sure that I just do not get the basic feature behind data.frame()
function and that would be valuable for me and might be to somebody else as
well.
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 all the learning I have achieved
through the 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