@hadley - Should this be added? Currently glue() & str_glue() fail inside of mutate() due to this data.table issue. However this might be out of scope for dtplyr to build in a workaround.
The point of this PR is to set .envir = .SD in glue or str_glue when they're used inside mutate():
devtools::load_all(".")
library(stringr)
df <- data.table(a = letters[1:3], b = letters[1:3])
df %>%
mutate(new = str_glue("{a}_{b}"))
#> Source: local data table [3 x 3]
#> Call: copy(`_DT1`)[, `:=`(new = str_glue("{a}_{b}", .envir = .SD))]
#>
#> a b new
#> <chr> <chr> <glue>
#> 1 a a a_a
#> 2 b b b_b
#> 3 c c c_c
#>
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results
Closes #344
@hadley - Should this be added? Currently
glue()
&str_glue()
fail inside ofmutate()
due to thisdata.table
issue. However this might be out of scope for dtplyr to build in a workaround.The point of this PR is to set
.envir = .SD
inglue
orstr_glue
when they're used insidemutate()
: