Re: [R] simple loop(?) analysing subsets

2010-07-18 Thread Joshua Wiley
Not to hijack the thread, but for my edification, what are the advantages/disadvantages of split() + lapply() compared to by()? Josh On Sun, Jul 18, 2010 at 9:50 PM, Dennis Murphy wrote: > Hi: > > Time to jack up your level of R knowledge, courtesy of the apply family. > > The 'R way' to do what

Re: [R] simple loop(?) analysing subsets

2010-07-18 Thread Dennis Murphy
Hi: Time to jack up your level of R knowledge, courtesy of the apply family. The 'R way' to do what you want is to split the data by species into list components, run lm() on each component and save the resulting lm objects in a list. The next trick is to figure out how to extract what you want,

Re: [R] simple loop(?) analysing subsets

2010-07-18 Thread Joshua Wiley
Hello, Take a look at ?by Something like: by(data, data[ , "species id"], function(x) {lm(o2con ~ bm, data = x)}) As an aside, it can be a bit cumbersome to deal with spaces in a variables name (because it has to be quoted then). Also since data is a function, something like mydata might make

[R] simple loop(?) analysing subsets

2010-07-18 Thread karmakiller
Hi All, I have a large data set with many columns of data. One of these columns is a species identifier and the remainder are variables such as temperature or mass. Currently I am carrying out a single regression on subsets of the data set, e.g. separated data sets with only the data from one spe