Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using dplyr functions on grouped data frame with variable of class yearmon generates error #1028

Closed
millerjef opened this issue Mar 18, 2015 · 1 comment

Comments

@millerjef
Copy link

I believe this issue is similar to resolved issue #390.

When using dplyr::group_by on a data frame containing a variable of class yearmon (zoo package), then I get:
Error: column 'yearMon' has unsupported type : yearmon

This occurs irrespective of whether the variable with class yearmon is one of the variables on which the data is to be grouped. I would also like to be able to group_by other variables with classes as defined by the zoo package (e.g., yearmon, yearqtr, etc.).

Please see minimum reproducible example:

library(zoo)
library(lubridate)
library(dplyr)

dataByDateAndLetter <- data.frame(
  time = sample(as.Date('2009-01-01') + 0:11, size = 20, replace = TRUE),
  letter = sample(c("a","b","c"), size = 20, replace = TRUE),
  x = rnorm(10,0,1)
)

dataByDateAndLetter <- mutate(dataByDateAndLetter, 
                                        time=ymd(time),
                                        yearMon=as.yearmon(time),
                                        yearQtr=as.yearqtr(time))

summaryDataByLetter <- dataByDateAndLetter %>%
  group_by(letter) %>% summarise(minX = min(x))

My environment (yes, I'm using a fairly old unstable build).

sessionInfo()
R Under development (unstable) (2014-09-17 r66626)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] tidyr_0.2.0     lubridate_1.3.3 zoo_1.7-11      dplyr_0.4.1    

loaded via a namespace (and not attached):
 [1] assertthat_0.1   DBI_0.3.1        digest_0.6.8     evaluate_0.5.5   formatR_1.0      grid_3.2.0       knitr_1.6       
 [8] lattice_0.20-30  lazyeval_0.1.10  magrittr_1.5     memoise_0.2.1    nycflights13_0.1 parallel_3.2.0   plyr_1.8.1      
[15] R6_2.0           Rcpp_0.11.3      stringr_0.6.2    tools_3.2.0     
@hadley
Copy link
Member

hadley commented May 19, 2015

Now part of #1105

@hadley hadley closed this as completed May 19, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jun 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants