-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Milestone
Description
This works:
library(dplyr)
mtcars %>%
mutate(xx=LETTERS[gear]) %>%
filter(xx==lag(xx))
This fails:
mtcars %>%
mutate(xx=LETTERS[gear]) %>%
filter(xx==lag(xx, default='foo'))
## Error in filter_impl(.data, dots) :
## Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'character'
Variants:
- works:
... %>% filter(carb == lag(carb, default=1))
(a numeric) - fails:
... %>% filter(as.character(xx) == lag(xx, default='foo'))
- works:
... %>% filter(xx == lag(as.character(xx), default='foo'))
(just by addingas.character
)
This behavior is new in dplyr-0.4.3
, I think.
sessionInfo()
## R version 3.2.2 (2015-08-14)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 8 x64 (build 9200)
##
## locale:
## [1] LC_COLLATE=English_United States.1252
## [2] LC_CTYPE=English_United States.1252
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] dplyr_0.4.3 readr_0.1.1
##
## loaded via a namespace (and not attached):
## [1] compiler_3.2.2 lazyeval_0.1.10 magrittr_1.5 R6_2.1.1
## [5] assertthat_0.1 parallel_3.2.2 DBI_0.3.1 tools_3.2.2
## [9] htmltools_0.2.6 Rcpp_0.12.0 rmarkdown_0.8 digest_0.6.8
Metadata
Metadata
Assignees
Labels
No labels