From 8ea8850ab0cf79d1894cf03de1930d61400b5bc8 Mon Sep 17 00:00:00 2001 From: David Budzynski Date: Sun, 5 Jun 2022 12:22:25 +0100 Subject: [PATCH] fix typos --- vignettes/datatable-programming.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vignettes/datatable-programming.Rmd b/vignettes/datatable-programming.Rmd index 46008e704..eb4ddf0e3 100644 --- a/vignettes/datatable-programming.Rmd +++ b/vignettes/datatable-programming.Rmd @@ -80,7 +80,7 @@ my_subset = function(data, col, val) { my_subset(iris, Species, "setosa") ``` -We have to use `deparse(substitute(...))` to catch the actual names of objects passed to function so we can construct the `subset` function call using those original names. Although ths provides unlimited flexibility with relatively low complexity, **use of `eval(parse(...))` should be avoided**. The main reasons are: +We have to use `deparse(substitute(...))` to catch the actual names of objects passed to function, so we can construct the `subset` function call using those original names. Although this provides unlimited flexibility with relatively low complexity, **use of `eval(parse(...))` should be avoided**. The main reasons are: - lack of syntax validation - [vulnerability to code injection](https://github.com/Rdatatable/data.table/issues/2655#issuecomment-376781159) @@ -143,7 +143,7 @@ substitute2( ) ``` -We can see in the output that both the functions names, as well as the names of the variables passed to those functions, have been replaced.. We used `substitute2` for convenience. In this simple case, base R's `substitute` could have been used as well, though it would've required usage of `lapply(env, as.name)`. +We can see in the output that both the functions names, as well as the names of the variables passed to those functions, have been replaced... We used `substitute2` for convenience. In this simple case, base R's `substitute` could have been used as well, though it would've required usage of `lapply(env, as.name)`. Now, to use substitution inside `[.data.table`, we don't need to call the `substitute2` function. As it is now being used internally, all we have to do is to provide `env` argument, the same way as we've provided it to the `substitute2` function in the example above. Substitution can be applied to the `i`, `j` and `by` (or `keyby`) arguments of the `[.data.table` method. Note that setting the `verbose` argument to `TRUE` can be used to print expressions after substitution is applied. This is very useful for debugging.