GithubHelp home page GithubHelp logo

Comments (10)

paul-buerkner avatar paul-buerkner commented on May 21, 2024 1

mutate_variables is now supported as well.

x <- as_draws_df(example_draws())
x <- subset(x, variable = c("mu", "tau"))

mutate_variables(x, tau2 = tau^2)
mutate_variables(x, scale = 1.96 * tau, lower = mu - scale)

from posterior.

mjskay avatar mjskay commented on May 21, 2024

Should we wish to use tidyverse-style NSE I believe the only dependency we need is rlang, which itself has no other dependencies (and which we already have a dependency on via tibble).

I don't think we would need to support more complex syntax available in select() (things like starts_with(), one_of(), etc), which would require a dependency on tidyselect, which itself has some other dependencies I don't think we already have (glue and purrr).

So supporting tidyverse NSE should in effect add no new dependencies (rlang would move from being an indirect to a direct dependency).

from posterior.

jgabry avatar jgabry commented on May 21, 2024

Should we wish to use tidyverse-style NSE I believe the only dependency we need is rlang

Yeah I think you're right that rlang is the only dependency we'd need for that. In my experience working with rlang a bit (although not a ton) I've found it to be super cool but also quite confusing. If I'm not using it consistently then every time I come back to it I have to reteach myself what everything means! Anyway, that doesn't mean we shouldn't use it, just that it could make our code base inaccessible to anyone who doesn't want to do a deep dive into rlang (which is probably most people). That's one of the annoying things about a lot of the source code for the tidyverse (not trying to criticize and it's probably unavoidable for them, but still unfortunate). Of course if we're just using it for a few things then that's no big deal and also probably worth it even if we use it a lot because it allows for nice features. Anyway, just thinking out loud.

from posterior.

paul-buerkner avatar paul-buerkner commented on May 21, 2024

Having the rlang dependency` is fine for me but I don't have much experience with its NSE semantics. @mjskay you presumably know how it works, right?

from posterior.

mjskay avatar mjskay commented on May 21, 2024

Yeah, I've used rlang's NSE stuff. It is largely a matter of adopt eval_tidy and/or quo instead of eval and quote; those functions resolve the tidyverse quasiquotation syntax for you (e.g. !!x or {{ x }} for substituting expressions). rename_variables would be relatively straightforward I think. mutate_variables might be more of a pain as I think it would require some format-specific verification that the result of the mutate can actually be stored in the format being used.

If we want this I can take a stab at it.

from posterior.

paul-buerkner avatar paul-buerkner commented on May 21, 2024

Thank you! I think it is a nice feature that people will ask for and I would be happy if you could take a shot at it. Perhaps starting with the draw_df class where things should be easier than for the other formats.

from posterior.

jgabry avatar jgabry commented on May 21, 2024

Same! Happy for you to take a stab at it, thanks! It does seem like a nice feature to offer.

from posterior.

paul-buerkner avatar paul-buerkner commented on May 21, 2024

Just a quick note that I am working on mutate_variables now.

from posterior.

jgabry avatar jgabry commented on May 21, 2024

Cool! One small thing from testthat:

test-mutate_variables.R:13: warning: mutate_variables works correctly for draws_df objects
Using `as.character()` on a quosure is deprecated as of rlang 0.3.0.
Please use `as_label()` or `as_name()` instead.

from posterior.

paul-buerkner avatar paul-buerkner commented on May 21, 2024

Thanks. Should be fixed now.

from posterior.

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.