moodymudskipper / tb

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

syntax for specific cases of separate ? #33

Closed moodymudskipper closed 4 years ago

moodymudskipper commented 4 years ago

once we've switched to <> for spread/gather

For some more complex cases we might use unglue, not all though.

library(dplyr)
df <- data.frame(x = c(NA, "a.b", "a.d", "b.c"))
df %>% separate(x, c("A", "B"))
df %tb>% .[`{A}.{B}` = x]

# If you just want the second variable:
df %>% separate(x, c(NA, "B"))
df %tb>% .[`{=.*?}.{B}` = x]
df %tb>% .[`{}.{B}` = x]
moodymudskipper commented 4 years ago

this df %tb>% .[{A}.{B}= x] would really be df %tb>% .[+unglue_data(x, "{A}.{B}"] so not sure if we need something new