Skip to content

Instantly share code, notes, and snippets.

@barryrowlingson
Created August 20, 2014 17:00
Show Gist options
  • Save barryrowlingson/316295a8264fedd1f766 to your computer and use it in GitHub Desktop.
Save barryrowlingson/316295a8264fedd1f766 to your computer and use it in GitHub Desktop.
dplyr doesn't preserve data frame classes
## 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