[R] apply lm function to dataset split by two variables

2011-09-28 Thread Elena Guijarro
Dear all, I am not fluent in R and am struggling to 1) apply a lm to a weight-size dataset, thus the model has to run separately for each species, each year; 2) extract coefs, r-squared, n, etc. The data look like this: yearsps cm w 200950 16 22 200950 17

Re: [R] apply lm function to dataset split by two variables

2011-09-28 Thread Dennis Murphy
Hi: Here's one way to do it with the plyr package: dd - read.table(textConnection( yearsps cm w 200950 16 22 200950 17 42 200950 18 45 200951 15 45 200951 16 53 200951 17 73 201050 15

Re: [R] apply lm function to dataset split by two variables

2011-09-28 Thread Michael Dewey
At 09:41 28/09/2011, Elena Guijarro wrote: Dear all, I am not fluent in R and am struggling to 1) apply a lm to a weight-size dataset, thus the model has to run separately for each species, each year; 2) extract coefs, r-squared, n, etc. The data look like this: yearsps cm w 2009