Probably an easy one:
I'd like to use tidyr
's gather_
on this data.frame
:
set.seed(1)
df <- data.frame(a=rnorm(10),b=rnorm(10),d=rnorm(10),id=paste0("id",1:10))
First, using gather
:
df %>% tidyr::gather(key=name,value=val,-id)
Gives me the desired outcome.
However, trying to match that with gather_
like this:
df %>% tidyr::gather_(key_col="name",value_col="val",gather_cols="id")
Doesn't give me what the gather
usage does.
Any idea?
I think you want:
Since you're gathering all columns except
id
. That said, if you're just looking to specify with character vectors,gather
is still an option (and as @Maurits Evers points out, the underscore-suffixed versions are deprecated) :