Re: [R] indexing in a function doesn't work?

2012-04-06 Thread Benjamin Caldwell
Josh Apologies I haven't responded earlier. This looks great - I ended up doing what I needed done piece-by-piece because of a looming deadline, but understanding this code and your suggestions below will be a weekend project. Many thanks for all your help. * * Best Ben On Tue, Apr 3, 2012 at

Re: [R] indexing in a function doesn't work?

2012-04-03 Thread Joshua Wiley
Hi Benjamin, You seem to have the right basic ideas, but a lot of your code had typos and some logic flaws that I guess came from trying to move from just code to in a function. I attached the changes I made. What I would strongly encourage you to do, is work through each of the little

Re: [R] indexing in a function doesn't work?

2012-04-02 Thread Petr PIKAL
Hi There is some mismatch in curly braces in your plotter function but when I try to use it I get plotter(10,3,fram=rwb,framvec=rwb$prcnt.char.depth,obj=prcnt.char.depth,form1= + post.f.crwn.length~shigo.av,form2=post.f.crwn.length~shigo.av-1, +

Re: [R] indexing in a function doesn't work?

2012-04-02 Thread Benjamin Caldwell
Petr, You can get an example dataset at http://dl.dropbox.com/u/3845242/torhelp.csv. I'll look at the rest of your suggestions in the morning, thanks for taking a look at it. Ben * * On Mon, Apr 2, 2012 at 10:33 PM, Petr PIKAL petr.pi...@precheza.cz wrote: Hi There is some mismatch in

[R] indexing in a function doesn't work?

2012-04-01 Thread Benjamin Caldwell
Hello, I've written a small function that's supposed to save me some time, and it's ending up killing it- the intention is to iteratively subset a dataset fram on framevec, fit a model (either lm or nls depending on type) and return the r2 or AIC from the model, respectively. Although as far as I

Re: [R] indexing in a function doesn't work?

2012-04-01 Thread Joshua Wiley
Hi, Glancing through your code it was not immediately obvious to me why it does not work, but I can see a lot of things that could be simplified. It would really help if you could give us a reproducible example. Find/upload/create (in R) some data, and examples of how you would use the function.

Re: [R] indexing in a function doesn't work?

2012-04-01 Thread Benjamin Caldwell
Josh, Many thanks - here's a subset of the data and a couple examples: plotter(10,3,fram=rwb,framvec=rwb$prcnt.char.depth,obj=prcnt.char.depth,form1= post.f.crwn.length~shigo.av,form2=post.f.crwn.length~shigo.av-1, form3=leaf.area~(1/exp(shigo.av*x))*n,type=2,xlm=70,ylm=35)