moodymudskipper / tb

IN ~PROGRESS my own take on `[.data.frame`
0 stars 0 forks source link

conditional mutating, `where` and `if` in arguments #26

Open moodymudskipper opened 4 years ago

moodymudskipper commented 4 years ago

where

We can have a where argument, and we'd mutate on these positions only. .subset will contain the filtered data and .data the unfiltered one. And the default would be to consider the filtered ones as it's faster and makes generally no difference, but we keep the flexibility.

We could propose a syntax similar to the along formula syntax but when doing by variable ifelse is good enough, especially with dot notation : foo[col = ifelse(is.na(.), "!", .)]

where should accept the same kind of input as i, appart from ++ rbinding.

Relevant : https://stackoverflow.com/questions/24459752/can-dplyr-package-be-used-for-conditional-mutating

if

Nothing stops us from implementing this :

foo[,, if (cond) a = 1 else b = 3]

That what purrr::when() and my own pif() are designed for but this would be much easier this way.

We could be as general as in standard mutate call, so support renaming and other advanced features, should work in s() too.

moodymudskipper commented 4 years ago

I guess where should support along feature too