Giter Site home page Giter Site logo

Comments (6)

etiennebacher avatar etiennebacher commented on June 18, 2024

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.

etiennebacher avatar etiennebacher commented on June 18, 2024

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.

DominiqueMakowski avatar DominiqueMakowski commented on June 18, 2024

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.

etiennebacher avatar etiennebacher commented on June 18, 2024

@strengejacke @IndrajeetPatil what do you think?

from datawizard.

strengejacke avatar strengejacke commented on June 18, 2024

#414 should fix this issue. (let's wait for checks...)

from datawizard.

strengejacke avatar strengejacke commented on June 18, 2024
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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.