[R] drop

From: Hans-Peter <gchappi_at_gmail.com>
Date: Thu 28 Sep 2006 - 13:57:08 GMT


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



R-help@stat.math.ethz.ch 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. Received on Fri Sep 29 00:16:14 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 28 Sep 2006 - 18:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.