[R] Assigning a factor to a data frame

arun smartpink111 at yahoo.com
Tue Jan 28 04:57:58 CET 2014



Hi,
Try:
Either:
 forsentest[1,] <- unlist(forsen[1,])
#or


forsen[] <- lapply(forsen,as.character)
forsentest[1,] <- forsen[1,]
A.K.




On Monday, January 27, 2014 10:38 PM, Tjun Kiat Teo <teotjunk at gmail.com> wrote:
I created an an empty data frame this way:

forsentest<-data.frame(matrix(nrow=nod,ncol=f)).

Then I tried to assign one row of another data frame forsen to it

forsentest[1,]<-forsen[1,]

But the factors in forsen gets converted to numbers in forsentest which is
not what I want.

Is there another way around it ?


Tjun Kiat

    [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.





More information about the R-help mailing list