> Even though I was looking in several r-books
> I could not find a suitable function to this problem
Which R books did you look through?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Feb 26, 2015 at 4:02 AM, David Studer wrote:
> Hello everybody!
>
> I have a (probabely very easy) prob
For the record, the ave function in R can apply any function you specify, not
just mean. The primary feature of ave is that it does not collapse the rows
like aggregate does. Choose among them according to how you want the output to
be organized.
-
Dear David,
your email is quite confusing. Do you want to get the sum for each group
(A,B,C) or each variable as would be indicated by your result?
sum by group:
aggregate(data=testdata,var1~group,sum)
count by group:
aggregate(data=testdata,var1~group,length)
sum by variable:
sum(na.omit(test
Hi David,
You have your answer in the question:
aggregate()
aggregate(cbind(var1,var2)~group, data=testdata, FUN=sum)
Although I am not sure what you intended to do with "testdata$x<-" as
the result cannot have the same number of rows than testdata
HTH,
Ivan
--
Ivan Calandra, ATER
Universi
Hello everybody!
I have a (probabely very easy) problem. Even though I was looking in
several r-books
I could not find a suitable function to this problem, that's why I hope
that someone here
could help me:
# Sample data:
group<-c("A","A","A","B","B","C","C","C")
var1<-c(1,0,0,1,1,0,NA,1)
var2<-c
5 matches
Mail list logo