我想计算数据中各列的样本偏差 [英] I want to calculate each column's sample deviation in data

查看:85
本文介绍了我想计算数据中各列的样本偏差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在基于包含3个名义变量和20个数字变量的数据学院"进行聚类分析.

I am doing cluster analysis based on data "college" which consists of 3 nominal and 20 numeric variables.

# 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"的底部.

Now what I want to know is how to calculate each column's sample variance and sample deviation and how to attach them to the bottom of the data set "cluster_1".

请让我知道.

推荐答案

  rbind(cluster_1, apply(cluster_1,2,sd), apply(cluster_1, 2, var) )

这篇关于我想计算数据中各列的样本偏差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆