[R] Integration and Loop in R

From: Lorenzo Isella <lorenzo.isella_at_gmail.com>
Date: Fri 04 Aug 2006 - 18:23:06 EST

Dear All,
I have seldom needed to use loops in R, but now I need to code a loop with a stride different from one.
In the R manual I downloaded I have the example:
> xc <- split(x, ind)
> yc <- split(y, ind)

> for (i in 1:length(yc)) {

    plot(xc[[i]], yc[[i]]);
    abline(lsfit(xc[[i]], yc[[i]]))
but in my case I'd like to add a condition so that i varies by 4 from one go to the following one. I cannot figure out the right syntax, can anyone help here?
Another thing (which could possibly solve my problem): I had a look at integrate command in R.
It seems to require an object defined as a function to carry out the
What if I simply have a list of data values? How can I coerce them into a function recognized by R? Furthermore, are there R routines to carry out the integration on a non-equally spaced 1D grid? Best Regards


R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri Aug 04 18:30:23 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 04 Aug 2006 - 20:18:43 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.