summary(s_complete$num_SNB) aggregate(num_SNB ~ Condition_SNB, data = s_complete, FUN = summary) sd(s_complete$num_SNB) count <- table(s_complete$num_SNB) please combine these computations in one code.
aggregate(s_complete$num_SNB~s_complete$Condition_SNB, FUN = function(x){ c(mean = mean(x), sd = sd(x), count = length(x)) })