Created
August 20, 2014 17:00
-
-
Save barryrowlingson/316295a8264fedd1f766 to your computer and use it in GitHub Desktop.
dplyr doesn't preserve data frame classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## make a data frame with a new class | |
d=data.frame(x=1:10,y=rnorm(10)) | |
class(d)=c("foo","data.frame") | |
class(d) | |
## [1] "foo" "data.frame" | |
## ordinary subsetting and subset preserve us: | |
## | |
class(d[1:5,]) | |
## [1] "foo" "data.frame" | |
class(subset(d,x<5)) | |
## [1] "foo" "data.frame" | |
## dplyr filter doesn't: | |
require(dplyr) | |
class(d %.% filter(x<5)) | |
## [1] "data.frame" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment