Re: [R] troubles with a for loop

2011-09-19 Thread R. Michael Weylandt
Alas, speaking before I check the optional argumentsc'est la vie. MW On Sun, Sep 18, 2011 at 3:00 PM, Jorge I Velez wrote: > Why wouldn't? It does for me ;-) > > curve(sin(x), 0, 10, col = 4, lwd = 2, las = 1) > curve(cos(x), 0, 10, add = TRUE) > > Best, > Jorge > > > On Sun, Sep 18, 2011 a

Re: [R] troubles with a for loop

2011-09-18 Thread Francesco Sarracino
Wow, thanks a lot for your quick replies and useful comments. Indeed, Sarah's advice does the job perfectly. I wish to thank you all also for your advices on how to shift from a Stata mindset to an R one (which is currently my main obstacle). Best, f. On 18 September 2011 20:07, R. Michael Weylan

Re: [R] troubles with a for loop

2011-09-18 Thread Jorge I Velez
Why wouldn't? It does for me ;-) curve(sin(x), 0, 10, col = 4, lwd = 2, las = 1) curve(cos(x), 0, 10, add = TRUE) Best, Jorge On Sun, Sep 18, 2011 at 2:07 PM, R. Michael Weylandt <> wrote: > Furthermore, if you want to add lines to a plot, I'd advise against the > curve() function, rather use

Re: [R] troubles with a for loop

2011-09-18 Thread R. Michael Weylandt
Furthermore, if you want to add lines to a plot, I'd advise against the curve() function, rather use lines() to add lines (or points() for, well, points) on a plot. E.g., x <- seq(0,10,by=0.025) y <- sin(x) y2 <- cos(x) plot(x,y,type="l",col="red4",lwd=3) lines(x,y2) curve() wouldn't work for t

Re: [R] troubles with a for loop

2011-09-18 Thread Patrick Burns
Sarah has told you how to get from where you are to where you want to be. However, it is easier to start somewhere else. The more "R" way to do what you are doing is to use a list to put the results of your regressions into. It is then very easy to use that list, and it is easier to keep track

Re: [R] troubles with a for loop

2011-09-18 Thread Sarah Goslee
You don't have a variable named pd.memb.i Instead, you need something like: get(paste("pd.memb.", i, sep="")) The error message you're getting, though, is because your loop syntax is wrong: for(i in 1:3) { do something } Sarah On Sun, Sep 18, 2011 at 12:05 PM, Francesco Sarracino wrote: > Dea

[R] troubles with a for loop

2011-09-18 Thread Francesco Sarracino
Dear all, I am a stata user and I am moving my first steps in R. I am dealing with a silly issue concerning looping over variables. I read previous posts on similar topics in the R help archive, but I did not find a solution. Here is my case: I run a simple bivariate linear regression saving the