moodymudskipper / tb

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

should `.by` be optional when spreading ? #22

Open moodymudskipper opened 4 years ago

moodymudskipper commented 4 years ago

We could display the explicit call, a bit like in dplyr joins when by is not explicit.

Desired behavior:

df <- data.frame(x = c("a", "b"), y = c(3, 4), z = c(5, 6))
df
#>   x y z
#> 1 a 3 5
#> 2 b 4 6
df %tb>% .[`{x}` = y]
#> In `.['{x}' = y]` using remaining column(s) as group(s), you might want to be explicit and use `.['{x}' = y, .by = "z"]`
#>   z  a  b
#> 1 5  3 NA
#> 2 6 NA  4

Created on 2020-01-27 by the reprex package (v0.3.0)

moodymudskipper commented 4 years ago

I'm not sure we should support this, it looks a lot like a mutate call so it's confusing, maybe by = NA could mean by is whatever columns were unmentioned ? we could leverage this for summarizing too.

moodymudskipper commented 4 years ago

implemented but not very robust at the moment as it doesn't handle the dot notation (if dot used on the right, we should find the names on the lhs).

moodymudskipper commented 4 years ago

Now the spreaded column is taken out thanks to https://github.com/moodymudskipper/tb/issues/36

This is not quite enough though, we should handle the "summarize_at" notation too.

moodymudskipper commented 4 years ago

now implemented, though not very economic as we recompute and reparse things that we went through before.