标签:frame image http nbsp png vector var div for
R语言中求数据框每一列的最大值、最小值、平均数、中位数、方差和标准差
1、
d <- data.frame(v1=sample(1:10,6),v2=sample(1:10,6),v3=sample(1:10,6),
v4=sample(1:10,6))
rmax <- vector()
rmin <- vector()
rmean <- vector()
rmed <- vector()
rvar <- vector()
rsd <- vector()
for (i in 1:ncol(d))
{
rmax = c(rmax,max(d[,i]))
rmin = c(rmin,min(d[,i]))
rmean = c(rmean,mean(d[,i]))
rmed = c(rmed,median(d[,i]))
rvar = c(rvar,var(d[,i]))
rsd = c(rsd,sd(d[,i]))
}
d <- rbind(d,rmax,rmin,rmean,rmed,rvar,rsd)
d
R语言中求数据框的每一列值的最大值、最小值、平均数、中位数、方差、标准差
标签:frame image http nbsp png vector var div for
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14671741.html