I am trying to be 'smart' and pipe into a summary function (in this case: quantile
) with an output length > 1, but without using summarise_at
etc.
Dummy data:
set.seed(1)
id = 1:20
value = sample (20:100, size = 20)
my_dat = data.frame( id, value)
So. My approach was the following:
require(dplyr)
#This data and operations are obviously simplified and do not reflect the entire complexity of my real data, but melt it down to the core of the problem)
my_dat %>% quantile(.$value, probs = seq(0, 1, 0.25), na.rm = TRUE)
#interestingly, I have to specify both the probs argument (why??)
#and add na.rm = TRUE in order to avoid a warning, although there are no NA's... ???
which gives a result, but not the correct one, because it basically takes both columns as argument.
0% 25% 50% 75% 100%
1.00 10.75 20.50 50.25 98.00
What is wrong with my code?
How to do this type of piping? I am stuck at how to basically isolate one column as vector and call a function on it.
If there is already a similar question out there many apologies for the dupe and very grateful if you could point me towards it.