Coder Social home page Coder Social logo

Comments (6)

moodymudskipper avatar moodymudskipper commented on September 21, 2024

I agree that my example using stop() might not be so useful, but x == 2 <- ~ . * 0.7 seems readable enough to me.

Your counter proposal is hard to implement because we might genuinely want to assign a list.

My proposal has weaker assumptions as it just assumes that you would rarely want to assign a function or a formula to a list element using our assignment functions.

If you think it's confusing we can drop the feature though, and see later if we miss it.

from inops.

karoliskoncevicius avatar karoliskoncevicius commented on September 21, 2024

I agree with you about the list - we might want to assign a list, so it fails in the general case, we can discard that.

I think we also have to keep in mind the possible benefit about the shorter notations. For example, would someone be persuaded to use the package so that they can do this:

x == 2 <- ~ . * 0.7

instead of this:

x[x==2] <- x[x==2] * 0.7

Or if we provide the subset alternatives, this seems even better:

(x %subset==% 2) * 0.7

Thou even for subset this standard way seems to be the shortest:

x[x==2] * 0.7

So in my mind the question is - do we gain some advantage from the formula syntax..

You will notice that I am quite conservative when it comes to adding new syntax :) I I think you are more willing to add complex syntax and explore new ideas. Will be interesting to see how this plays out in working on this package.

from inops.

moodymudskipper avatar moodymudskipper commented on September 21, 2024

Maybe it's better to be more conservative to start with.

I like the feature because to me variable repetition comes with increased cognitive load, and the syntax x < 2 <- 42 is really just to avoid x[x < 2] <- 42 so supporting functions goes a step further in the same direction, plus with a longer variable names you can get something like :

some_df$some_var == 2 <- ~ . * 0.7 # rather than :
some_df$some_var[some_df$some_var == 2] <- some_df$some_var[some_df$some_var == 2] * 0.7

With my package dotdot I would do :

some_df$some_var[some_df$some_var == 2] := .. * 0.7

But I understand we're talking about advanced features before having the basics laid out. I'll remove it for now.

from inops.

karoliskoncevicius avatar karoliskoncevicius commented on September 21, 2024

Agreed about some_df$some_var situation.

I am starting to like to formula solution. But maybe we can implement it without ~ and rlang dependency? So just:

some_df$some_var == 2 <- . * 0.7

And we agree to use dot as a placeholder for the x.

from inops.

moodymudskipper avatar moodymudskipper commented on September 21, 2024

Unfortunately some_df$some_var == 2 <- . * 0.7 is not possible because foo<- functions always evaluate the rhs before even entering the function.

Making the rhs a formula was a way to use NSE here.

from inops.

moodymudskipper avatar moodymudskipper commented on September 21, 2024

Let's reopen this if we miss it later, and move forward with simpler scope

from inops.

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.