Using n() at the same time as calculating other summary statistics
问题 I am having trouble to prepare a summary table using dplyr based on the data set below: set.seed(1) df <- data.frame(rep(sample(c(2012,2016),10, replace = T)), sample(c('Treat','Control'),10,replace = T), runif(10,0,1), runif(10,0,1), runif(10,0,1)) colnames(df) <- c('Year','Group','V1','V2','V3') I want to calculate the mean, median, standard deviation and count the number of observations by each combination of Year and Group . I have successfully used this code to get mean , median and sd :