[R] drop
Hans-Peter
gchappi at gmail.com
Thu Sep 28 15:57:08 CEST 2006
Hello,
What's the best/recommended way to drop the dimension of a data.frame?
Probably "test[,,]" but I am not sure. I would prefer an explicit
function, but drop doesn't work with frames and I didn't find
something in the helpfiles/mailarchive.
Example:
test <- data.frame( x = 1:7 )
str( drop( test ) ) # still a data.frame
str( test[,, drop = TRUE] ) # ok
str( test[,,] ) # ok <== IS THIS THE WAY TO DO IT?
str( as.integer( as.matrix( test ) ) ) # ok
str( drop( as.matrix( test ) ) ) # ~ok, named integer
test2 <- test
attributes( test2 ) <- NULL
str( drop( as.matrix( test2 ) ) ) # ok
Thanks and best regards,
Hans-Peter
PS: how could I lookup the code for subsetting a data.frame. I suppose
that it is in "data.frame.["
More information about the R-help
mailing list