This is the data I have now, and it is a dataset with students from different education levels(F1) and several variables about their academic performancedata And I want to use R to make a table of descriptive statistics like this one Result, which has the mean and standard deviation of each variable group by their education level.
aggregate(. ~ F1, dt3, function(x) c(mean = mean(x), sd = sd(x)))
I have used this function, but the result is not identical to the one I want.
Here is a mini sample of my data.
structure(list(F1 = c("Elementary school", "High_school", "High_school", "Elementary school", "Junior_high_school", "High_school", "Kindergarten", "Kindergarten"), X1 = c(0, 0, 0, 0, 0, 0, 0, 0), X2 = c(1, 1, 0, 0, 0, 0, 1, 1), X3 = c(1, 1, 1, 0, 0, 0, 0, 1), X4 = c(1, 1, 1, 1, 0, 1, 1, 1), X5 = c(4, 4, 4, 4, 1, 1, 4, 4), X6 = c(4, 4, 3, 4, 1, 2, 4, 4), X7 = c(4, 4, 3, 4, 3, 1, 4, 4), X8 = c(4, 4, 3, 4, 1, 1, 4, 4), Y1 = c(4, 4, 3, 4, 2, 3, 4, 4), Y2 = c(4, 3, 4, 3, 4, 3, 4, 4)), row.names = c(1L, 2L, 5L, 14L, 696L, 15L, 1348L, 1364L), class = "data.frame")