Re: [R] summarizing a dataset on a factor

2014-03-27 Thread Tom Wright
Thanks David, Neat use of merge there. I think I can also do this with: ddply(data,.(id),f) On Thu, 2014-03-27 at 16:06 -0500, David Carlson wrote: > It may be possible to do this in a single step, but > > > x1 <- aggregate(response~id+age, data, mean) > > x2 <- data[data$eye=="l", c("id", "res

Re: [R] summarizing a dataset on a factor

2014-03-27 Thread David Carlson
It may be possible to do this in a single step, but > x1 <- aggregate(response~id+age, data, mean) > x2 <- data[data$eye=="l", c("id", "response2")] > merge(x1, x2) id age response response2 1 1 2 4.60 High 2 2 9 2.65 High 3 3 5 3.65 High 4 4 2 7.55