Re: [R] Indexing a matrix within loops

2010-03-13 Thread Jorge Ivan Velez
Hi Josh, Here is one way: with(x, aggregate(x[,-3], list(factor.level), mean, na.rm = TRUE)) HTH, Jorge On Sat, Mar 13, 2010 at 1:50 PM, Josh B <> wrote: > Hi, > > I was hoping someone could help me with the following problem. Consider > this toy example. For the input dataset there are four i

Re: [R] Indexing a matrix within loops

2010-03-13 Thread michael watson (IAH-C)
aggregate(x[,1:2], by=list(factor=x$factor.level), mean) From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of Josh B [josh...@yahoo.com] Sent: 13 March 2010 18:50 To: R Help Subject: [R] Indexing a matrix within loops Hi, I was

[R] Indexing a matrix within loops

2010-03-13 Thread Josh B
Hi, I was hoping someone could help me with the following problem. Consider this toy example. For the input dataset there are four individuals (rows "indv.1" through "indv.4"), measured for two different variables (columns "var.1" and "var.2") at two different levels of a factor (column "factor