Mutate a data frame by the mutate terms from ...
.
mutate_nse( .data, ..., mutate_nse_split_terms = TRUE, mutate_nse_env = parent.frame(), mutate_nse_warn = TRUE, mutate_nse_printPlan = FALSE )
.data | data.frame |
---|---|
... | expressions to mutate by. |
mutate_nse_split_terms | logical, if TRUE into separate mutates (if FALSE instead, pass all at once to dplyr). |
mutate_nse_env | environment to work in. |
mutate_nse_warn | logical, if TRUE warn about name re-use. |
mutate_nse_printPlan | logical, if TRUE print the expression plan |
.data with altered columns.
Note: this method as the default setting mutate_nse_split_terms = TRUE
, which is
safer (avoiding certain known dplyr
/dblyr
issues)
(please see the side-notes of https://winvector.github.io/FluidData/partition_mutate.html for some references).
limit <- 3.5 datasets::iris %.>% mutate_nse(., Sepal_Long := Sepal.Length >= 2 * Sepal.Width, Petal_Short := Petal.Length <= limit) %.>% head(.)#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species Sepal_Long #> 1 5.1 3.5 1.4 0.2 setosa FALSE #> 2 4.9 3.0 1.4 0.2 setosa FALSE #> 3 4.7 3.2 1.3 0.2 setosa FALSE #> 4 4.6 3.1 1.5 0.2 setosa FALSE #> 5 5.0 3.6 1.4 0.2 setosa FALSE #> 6 5.4 3.9 1.7 0.4 setosa FALSE #> Petal_Short #> 1 TRUE #> 2 TRUE #> 3 TRUE #> 4 TRUE #> 5 TRUE #> 6 TRUE#> Warning: seplyr::mutate_se possible name conflicts in assigment#> x y #> 1 2 2