Comments (6)
ok, I think the docs are fine. regex
modulates the select-string when we don't have select-helpers, and if we have select-helpers, we only have regular expressions
from datawizard.
The proper regex is \\.
otherwise it selects everything:
library(datawizard)
iris |>
data_select(contains("\\.")) |>
head()
#> Sepal.Length Sepal.Width Petal.Length Petal.Width
#> 1 5.1 3.5 1.4 0.2
#> 2 4.9 3.0 1.4 0.2
#> 3 4.7 3.2 1.3 0.2
#> 4 4.6 3.1 1.5 0.2
#> 5 5.0 3.6 1.4 0.2
#> 6 5.4 3.9 1.7 0.4
I can update the readme
from datawizard.
But regex
is set to FALSE
.
I think the problematic code is here:
.select_helper <- function(expr, data, ignore_case, regex, verbose) {
lst_expr <- as.list(expr)
# need this if condition to distinguish between starts_with("Sep") (that we
# can use directly) and starts_with(i) (where we need to get i)
if (length(lst_expr) == 2L && typeof(lst_expr[[2]]) == "symbol") {
collapsed_patterns <- .dynGet(lst_expr[[2]], inherits = FALSE, minframe = 0L)
} else {
collapsed_patterns <- paste(unlist(lst_expr[2:length(lst_expr)]), collapse = "|")
}
helper <- insight::safe_deparse(lst_expr[[1]])
rgx <- switch(helper,
"starts_with" = paste0("^(", collapsed_patterns, ")"),
"ends_with" = paste0("(", collapsed_patterns, ")$"),
"contains" = paste0("(", collapsed_patterns, ")"),
"regex" = collapsed_patterns,
insight::format_error("There is no select helper called '", helper, "'.")
)
grep(rgx, colnames(data), ignore.case = ignore_case)
}
Argument regex
is passed, but not evaluated.
from datawizard.
If we want a different behaviour, we should somewhere mention this in the code. The code from the readme used to work, i.e. contains(".")
selected everything with dots when regex
was FALSE
.
from datawizard.
But I thought regex
only applies when select
is a character (and that's what the docs say) so whether regex
is TRUE
or FALSE
shouldn't matter in the example above
from datawizard.
But I thought
regex
only applied when select was a character (and that's what the docs say) so whetherregex
isTRUE
orFALSE
shouldn't matter in the example above
Yes. It was maybe an old artifact from the readme examples.
from datawizard.
Related Issues (20)
- Request for warnings or errors added to reverse() HOT 2
- CRAN failures HOT 5
- Rename `add_labs()` HOT 5
- `weighted` functions should better deal with `NA` values. HOT 4
- Fix order dependency in unit tests HOT 8
- `standardize()` fails with `Surv` objects when namespaces are used HOT 8
- Problem with datawizard for others packages HOT 1
- tibble-issue
- data_select(): add option to evaluate a function passed to `select` HOT 6
- dw_transformer hits again HOT 19
- `remove_na` vs. `na.rm` HOT 6
- Add select helpers to `data_to_wide` and friends HOT 8
- Plots for describe_distribution() and data_tabulate() HOT 3
- Need better error for `describe_distribution()` with character column
- datawizard versions of separate() and unite() HOT 3
- GHA fails on macOS HOT 3
- Update vignette "Coming from tidyverse"
- Release checklist for 0.8.0 HOT 2
- `standardize()` fails in some cases HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datawizard.