Skip to content

Data.frame manipulation

7 messages · AC Del Re, Dennis Murphy, PIKAL Petr

#
HI

r-help-bounces at r-project.org napsal dne 28.01.2010 04:35:29:
multiple
effect
first row
Do not use cbind. Its output is a matrix and in this case character 
matrix. Resulting data frame will consist from factors as you can check by 


str(data)

data<-data.frame(id=id,es=es,mod1=mod1,mod2=mod2)
E.g. aggregate

aggregate(data[, -(3:4)], data[,3:4], mean)
  mod1   mod2 id  es
1    4 calpas  2 0.3
2    1   itas  3 0.2
3    1  other  3 0.3
4    4  other  2 0.1
5    1    wai  3 0.1
6    2    wai  1 0.3

doBy or tapply or ddply from plyr library or ....

Regards
Petr
and
http://www.R-project.org/posting-guide.html
#
Hi

r-help-bounces at r-project.org napsal dne 28.01.2010 17:40:01:
about
for
output):
mean))
in
If I remember it correctly in my suggestion I used something like

aggregate(x[,-columns.mod1 and mod2], by = x[, columns.mod1 and mod2, 
mean)

Which shall use mod2 as aggregating variable.

Does it result in output you wanted?

Regards
Petr
wrote:
check by
id
http://www.R-project.org/posting-guide.html