user3022875 - 5 months ago 51

R Question

I have this data frame

`first = quantile(c(1,2,3),c(.5,.6))`

second = quantile(c(7,78,8),c(.5,.6))

main =as.data.frame(rbind(first, second))

main$group = cbind( as.character(rownames(main) ) )

main

50% 60% group

first 2 2.2 first

second 8 22.0 second

and I would like to transform it with gather but I get the error:

`main %>% gather(key= Percentile, value = value, c("50%","60%"))`

`Error: All select() inputs must resolve to integer column positions.`

The following do not:

* c("50%", "60%")

result should be:

`group Percentile value`

first 50% 2

first 60% 2.2

second 50% 8

second 60% 22

thank you

Answer

Here it is:

```
main %>% gather(Percentile, value = value,c(`50%`, `60%`))
```

`group Percentile value 1 first 50% 2.0 2 second 50% 8.0 3 first 60% 2.2 4 second 60% 22.0`