On Sep 9, 2015, at 5:51 PM, Pete St Marie wrote:
> Thanks David.
>
> Sorry, I should have been clearer in my question.
>
> I know how to avoid the problem, I was just wondering if I was trying to do something not supported. I do a lot of work with dates in yearmon, converting back and forth to character just gives me more places to make an error.
>
> Looking at the problems closed with the one referenced above (in particular #1028), it seemed to me that the zoo classes should be working.
Agree that was what one would have assumed from reading PR#1028 and the linked problems. So here's my error and setup:
> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
Running under: OS X 10.7.5 (Lion)
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] grDevices utils datasets stats graphics grid methods
[8] base
other attached packages:
[1] rms_4.3-1 SparseM_1.7 Hmisc_3.16-0 ggplot2_1.0.1
[5] Formula_1.2-1 survival_2.38-3 sos_1.3-8 brew_1.0-6
[9] lattice_0.20-33
loaded via a namespace (and not attached):
[1] Rcpp_0.12.0 RColorBrewer_1.1-2 plyr_1.8.3
[4] tools_3.2.1 rpart_4.1-10 digest_0.6.8
[7] polspline_1.1.12 gtable_0.1.2 nlme_3.1-122
[10] Matrix_1.2-2 mvtnorm_1.0-3 proto_0.3-10
[13] gridExtra_2.0.0 stringr_1.0.0 cluster_2.0.3
[16] MatrixModels_0.4-1 nnet_7.3-10 foreign_0.8-66
[19] multcomp_1.4-1 latticeExtra_0.6-26 TH.data_1.0-6
[22] reshape2_1.4.1 magrittr_1.5 codetools_0.2-14
[25] scales_0.3.0.9000 MASS_7.3-44 splines_3.2.1
[28] colorspace_1.2-6 quantreg_5.18 sandwich_2.3-3
[31] stringi_0.5-5 acepack_1.3-3.3 munsell_0.4.2
[34] zoo_1.7-12
> library(dplyr)
Attaching package: ‘dplyr’
The following objects are masked from ‘package:Hmisc’:
combine, src, summarize
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
> library(zoo)
Attaching package: ‘zoo’
The following objects are masked from ‘package:base’:
as.Date, as.Date.numeric
>
> foo <- structure(list(dates = structure(c(2L, 1L, 3L),
+ .Label = c("Feb 2015",
+ "Jan 2015",
+ "Mar 2015"),
+ class = "factor"),
+ var1 = c(1, 2, 3)),
+ .Names = c("dates", "var1"),
+ row.names = c(NA, -3L),
+ class = "data.frame")
>
> bar <- structure(list(dates = structure(c(2L, 1L, 3L),
+ .Label = c("Feb 2015",
+ "Jan 2015",
+ "Mar 2015"),
+ class = "factor"),
+ var2 = c(10, 20, 30)),
+ .Names = c("dates", "var2"),
+ row.names = c(NA, -3L),
+ class = "data.frame")
>
> baz <- full_join(foo, bar) # ok
Joining by: "dates"
>
> foo$dates <- as.yearmon(foo$dates)
> bar$dates <- as.yearmon(bar$dates)
>
> qux <- full_join(foo, bar) # nope
Joining by: "dates"
Error: cannot join on columns 'dates' x 'dates': Can't join on 'dates' x 'dates' because of incompatible types (yearmon / yearmon)
--
David.