Skip to content

support for dplyr::across? #154

@edavidaja

Description

@edavidaja

across is very exciting--I was hoping to use it to solve a problem like this a bit more readably.

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(dtplyr)

lazy_dt(iris) %>% 
  mutate(
    across(starts_with("Sepal"), ~ .x^2, .names = "{col}_squared")
  )
#> Source: local data table [?? x 6]
#> Call:   copy(`_DT1`)[, `:=`(`across(starts_with("Sepal"), ~.x^2, .names = "{col}_squared")` = across(starts_with("Sepal"), 
#>     ~.x^2, .names = "{col}_squared"))]
#> Error: peek_mask() must only be used inside dplyr verbs

Created on 2020-04-07 by the reprex package (v0.3.0)

Session info
sessionInfo()
#> R version 3.6.3 (2020-02-29)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19592)
#> 
#> Matrix products: default
#> 
#> 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 datasets  utils     methods   base     
#> 
#> other attached packages:
#> [1] dtplyr_1.0.1.9000 dplyr_0.8.99.9002
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.4        knitr_1.28        magrittr_1.5      tidyselect_1.0.0 
#>  [5] R6_2.4.1          rlang_0.4.5.9000  fansi_0.4.1       stringr_1.4.0    
#>  [9] highr_0.8         tools_3.6.3       data.table_1.12.8 xfun_0.12        
#> [13] cli_2.0.2         htmltools_0.4.0   ellipsis_0.3.0    yaml_2.2.1       
#> [17] digest_0.6.25     assertthat_0.2.1  tibble_3.0.0      lifecycle_0.2.0  
#> [21] crayon_1.3.4      purrr_0.3.3       vctrs_0.2.99.9010 glue_1.4.0       
#> [25] evaluate_0.14     rmarkdown_2.1     stringi_1.4.6     compiler_3.6.3   
#> [29] pillar_1.4.3      generics_0.0.2    renv_0.9.3        pkgconfig_2.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    dplyr-compat 💞dplyr compatibility issuesfeaturea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions