0

I want to get the mean and sd for several columns in a tibble.

I tried to pass the column as variable to summarise as the following:

t<-tibble(col1=1:10,col2=3)
s="col1"
t %>%
  dplyr::summarise(Mean=mean(noquote(s),na.rm=T),
                   sd=sd(noquote(s),na.rm=T))

This didn't work, it is giving

 Mean SD
1   NA NA    

How to pass the column name as variable to dplyr summarise?

Mariya
  • 847
  • 1
  • 9
  • 25

0 Answers0