Comments (6)
You can evaluate the function beforehand and use its output:
library(datawizard)
model <- lm(Petal.Length ~ Petal.Width, data=iris)
cols <- insight::find_predictors(model, effects = "fixed", flatten = TRUE)
head(data_select(iris, cols))
#> Petal.Width
#> 1 0.2
#> 2 0.2
#> 3 0.2
#> 4 0.2
#> 5 0.2
#> 6 0.4
There are already many arguments in functions that use select helpers so I don't think adding force_eval
would be worth it.
from datawizard.
Also, in this case it would be easy but if you want to do this in a custom function then evaluating can be tricky:
foo <- function(effects) {
data_select(iris, insight::find_predictors(model, effects = effects, flatten = TRUE))
}
Evaluating insight::find_predictors(model, effects = effects, flatten = TRUE)
would error because we need to get effects
first
from datawizard.
or maybe a safeguard, like try to running the caught function on the data (as it is primarily expected) and if it fails try to run the expression on its own and if it fails again then throw an error
from datawizard.
@strengejacke @IndrajeetPatil what do you think?
from datawizard.
#414 should fix this issue. (let's wait for checks...)
from datawizard.
library(datawizard)
model <- lm(Petal.Length ~ Petal.Width, data=iris)
head(data_select(iris, insight::find_predictors(model, effects = "fixed", flatten = TRUE)))
#> Petal.Width
#> 1 0.2
#> 2 0.2
#> 3 0.2
#> 4 0.2
#> 5 0.2
#> 6 0.4
effects <- "fixed"
head(data_select(iris, insight::find_predictors(model, effects = effects, flatten = TRUE)))
#> Petal.Width
#> 1 0.2
#> 2 0.2
#> 3 0.2
#> 4 0.2
#> 5 0.2
#> 6 0.4
Created on 2023-05-02 with reprex v2.0.2
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
- 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
- Select-helper with "." doesn't work as expected? HOT 6
- `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.