我正在根据数据“大学”进行聚类分析,该数据由3个名义变量和20个数字变量组成。
# select the columns based on the clustering results
cluster_1 <- mat[which(groups==1),]
#"cluster_1" is a data set which is made by cluster analysis consisting of 125 observations.
rbind(cluster_1[, -(1:3)], colMeans(cluster_1[, -(1:3)]))
#This is process of calculating each column's mean and attach the means to the bottom of the data set, "cluster_1".
现在我想知道的是如何计算每个列的样本方差和样本偏差以及如何将它们附加到数据集“cluster_1”的底部。
请告诉我。
答案 0 :(得分:0)
rbind(cluster_1, apply(cluster_1,2,sd), apply(cluster_1, 2, var) )