I am teaching myself to use tidyverse more, as I'm hoping to be able to make cleaner code in the future.
I have data that looks like this:
data <- as_tibble(data.frame(x = c(1,2,3,3,4),
y = c(3,4,4,2,5),
z = c(1,1,5,5,3)))
And I would like to get the mean, sd, and confidence intervals for all 3 columns.
The code I am hoping to use is this:
data %>%
summarize_at(vars(x:z), list(mean=mean, sd=sd, cilow = ci[2], cihigh = ci[3]))
where the ci() function is from the gmodels package. When passing a single variable through ci, you can pick which output column to view, but when it's part of a list of functions, I get the error
Error in ci[2] : object of type 'closure' is not subsettable
Any advice/suggestions are appreciated! I am trying not to manually calculate all the CIs (my actual data has many more variables to calculate)