由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - R question, calculate mean over some rows
相关主题
sas coding help needed问一个用sas解决epidemiology的问题
双包子求教:SAS问题[合集] how to calculate column sum not row sum in SAS? thanks a lo
SAS Graphic question - help pleasemultinomial distribution: how to derive the covariance of different variable
mixed models如何在data step里实现多个变量分类后进行一系列的计算?
请教关于SAS表格输出的问题how to delete rows by string value?
请教一道作业题目问个r问题
问个P-VALUE的问题包子问一个统计基本概念
[合集] 我是否应该将Insignificant Interaction还放在Model里?A question about basic statistics, thanks.
相关话题的讨论汇总
话题: var100话题: mean话题: rows话题: calculate话题: var1
进入Statistics版参与讨论
1 (共1页)
s*******d
发帖数: 132
1
I have an id variable, and hundreds of covariates var1- var100.
There are some id are the same with each other. For these rows with the same
id, I need to calculate the mean for var1 - var100, respectively.
How to do this in R? Thanks.
d********t
发帖数: 837
2
ddply in the plyr package.
D******n
发帖数: 2836
3
aggregate

same

【在 s*******d 的大作中提到】
: I have an id variable, and hundreds of covariates var1- var100.
: There are some id are the same with each other. For these rows with the same
: id, I need to calculate the mean for var1 - var100, respectively.
: How to do this in R? Thanks.

s*******d
发帖数: 132
4
Thanks.

【在 D******n 的大作中提到】
: aggregate
:
: same

S******y
发帖数: 1123
5
Compute group means in R
There are several ways to compute means by groups in R.
For example, if you would like to computer average score by gender, you can
achieve that in one of the following three ways -
1) plotmeans(score ~ gender)
will plot group means and confidence intervals.
(it requires gplot package)
2) aggregate(score, list(gender_class = gender), mean)
will split the data into subsets, computes summary statistics for each
3) tmp=split(score, gender)
sapply(tmp, mean)
‘split’ divides the data into groups
'sapply' applies mean function to a list of elements
1 (共1页)
进入Statistics版参与讨论
相关主题
A question about basic statistics, thanks.请教关于SAS表格输出的问题
SAS可以定义一个未知维数的ARRAY么?请教一道作业题目
问个概念。问个P-VALUE的问题
急问一个analysis of covariance的问题[合集] 我是否应该将Insignificant Interaction还放在Model里?
sas coding help needed问一个用sas解决epidemiology的问题
双包子求教:SAS问题[合集] how to calculate column sum not row sum in SAS? thanks a lo
SAS Graphic question - help pleasemultinomial distribution: how to derive the covariance of different variable
mixed models如何在data step里实现多个变量分类后进行一系列的计算?
相关话题的讨论汇总
话题: var100话题: mean话题: rows话题: calculate话题: var1