Re: [R] simplify source code

2011-12-01 Thread Christof Kluß
Hi now I'd like to do for (colname in c('ColName1','ColName2','ColName3')) { dat - measurements$colname But that does not work, though I can write measurements$C1 (same as measurements$C1) (but different to measurements[C1]!) Can you give me a hint? greetings Christof Am

Re: [R] simplify source code

2011-12-01 Thread jim holtman
measurements[[colname]] ?'[[' On Thu, Dec 1, 2011 at 8:34 AM, Christof Kluß ckl...@email.uni-kiel.de wrote: Hi now I'd like to do for (colname in c('ColName1','ColName2','ColName3')) {    dat - measurements$colname But that does not work, though I can write measurements$C1 (same as

Re: [R] simplify source code

2011-11-29 Thread Christof Kluß
Hi Dennis, thank you very much. That works fine. Is there a possibility that R continue even if one of the models is not solvable? R currently terminates with an error message. greetings Christof Am 27-11-2011 01:34, schrieb Dennis Murphy: vars- c('y1', 'y2', 'y3') # Function to create

Re: [R] simplify source code

2011-11-29 Thread R. Michael Weylandt
Look into tryCatch() for error handling. Michael On Tue, Nov 29, 2011 at 7:01 AM, Christof Kluß ckl...@email.uni-kiel.de wrote: Hi Dennis, thank you very much. That works fine. Is there a possibility that R continue even if one of the models is not solvable? R currently terminates with an

[R] simplify source code

2011-11-26 Thread Christof Kluß
Hi I would like to shorten mod1 - nls(ColName2 ~ ColName1, data = table, ...) mod2 - nls(ColName3 ~ ColName1, data = table, ...) mod3 - nls(ColName4 ~ ColName1, data = table, ...) ... is there something like cols = c(ColName2,ColName3,ColName4,...) for i in ... mod[i-1] - nls(ColName[i] ~

Re: [R] simplify source code

2011-11-26 Thread Dennis Murphy
Hi: Here's one way you could do it. I manufactured some fake data with a simple model to illustrate. This assumes you are using the same model formula with the same starting values and remaining arguments for each response. dg - data.frame(x = 1:10, y1 = sort(abs(rnorm(10))),