example data
df <- structure(list(d = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), l1 = c(1.5,
1.5, 1.5, 1.5, 1.5, 1.5, 2, 2, 2, 2, 2, 2), l2 = c(1.83333333333333,
1.83333333333333, 2.16666666666667, 2.16666666666667, 2.5, 2.5,
2.33333333333333, 2.33333333333333, 2.66666666666667, 2.66666666666667,
3, 3), l3 = c(2.33333333333333, 2.83333333333333, 2.66666666666667,
3.16666666666667, 3, 3.5, 2.83333333333333, 3.33333333333333,
3.16666666666667, 3.66666666666667, 3.5, 4)), class = "data.frame", row.names = c(NA,
-12L), .Names = c("d", "l1", "l2", "l3"))
head(df)
d l1 l2 l3
1 1 1.5 1.833333 2.333333
2 1 1.5 1.833333 2.833333
3 1 1.5 2.166667 2.666667
4 1 1.5 2.166667 3.166667
5 1 1.5 2.500000 3.000000
6 1 1.5 2.500000 3.500000
intention
gather all columns of df into x,y.
current UI
df %>% gather(x, y, d:l3)
request
It would be nice if gather had an all-inclusive default when only key and value arguments are provided. This seems like the most intuitive default to me as I don't think you'd ever want to gather
no columns into a key and value... This would mean that for df the following "smart default" would be equivalent to the current UI (gather all columns).
the select() philosophy
Would this be confusing? Does it go against select()?
Now I think this impacts the whole opposite to the select() paradigm. That is if ... is NULL it current selects nothing... but what is the use case for selecting nothing? There are definitely some use cases for selecting everything ( such as that within gather() ).
In the quest of making code more naturally reader friendly an empty selection giving everything is definitely a negative... so perhaps an alternative solution:
df %>% gather(x, y, all= TRUE)
df %>% gather_all_into(x, y)
df %>% gather_into(x, y) # think: spread_outof(x,y) to reverse?
but my favorite...
df %>% into(x, y) # opens the door to 'outfrom()` / `outof`
example data
intention
gather all columns of df into x,y.
current UI
request
It would be nice if
gatherhad an all-inclusive default when onlykeyandvaluearguments are provided. This seems like the most intuitive default to me as I don't think you'd ever want to gatherno columns into a key and value... This would mean that for
dfthe following "smart default" would be equivalent to the current UI (gather all columns).the
select()philosophyWould this be confusing? Does it go against
select()?Now I think this impacts the whole opposite to the
select()paradigm. That is if...isNULLit current selects nothing... but what is the use case for selecting nothing? There are definitely some use cases for selecting everything ( such as that withingather()).In the quest of making code more naturally reader friendly an empty selection giving everything is definitely a negative... so perhaps an alternative solution:
but my favorite...