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.["

______________________________________________
[email protected] 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.

Reply via email to