Closed hope-data-science closed 4 years ago
Good idea, I will definitely implement this in the next release. If we have character started with ^ or ended with $ then we will expand it to column names. But note that we haven't parametric evaluation in this case:
# dplyr
my_vars = "Se"
iris %>% select(starts_with(my_vars )) # work
# maditr
my_vars = "^Se"
iris %>% dt_select(my_vars ) # will not work
While ^ and $ are good, but dplyr::contains
might also be useful. Perhaps provide a new parameter like "regex"?
Thanks.
You can describe any name with "^" and "$", e. g. "^.*my_string"
is equivalent to contains("my_string")
. However I will think about general API for variable selectors.
I have tried too, but I could not support Sepal.Length:Petal.Length
for select() so far.
See https://hope-data-science.github.io/tidydt/reference/select_dt.html.
In
dplyr
, we haveiris %>% select(starts_with("Se"))
. Inmaditr
, the analogous way isiris %>% dt_select(startsWith(colnames(.),"Se"))
.Is there some way to make it more convenient? Such as:
iris %>% dt_select("^Se")
Once receive a character, understand it as a regular expression.