Pretty simple question, and I have had a quick search in google and stackoverflow. I found this in another post: In aggregate: sum not meaningful for factors.
df[] <- lapply(df, function(x) type.convert(as.character(x)))
how does df[]
work?
To add to what Roland wrote,{edit} aaagh he ninja'd me w/ his comment the point is that using DF[]
retains the existing object DF
with its attributes, in this case the fact that it's got two dimensions and the names a
and b
.
Rgames> foo<- matrix(1:6,2,3)
Rgames> foo[]<-7:12
Rgames> foo
[,1] [,2] [,3]
[1,] 7 9 11
[2,] 8 10 12
Rgames> foo<-7:12
Rgames> foo
[1] 7 8 9 10 11 12
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With