Re: [R] converting a for loop into a foreach loop

2012-01-23 Thread kalee
Thanks Jim, that's worked On 24 January 2012 00:49, jholtman [via R] < ml-node+s789695n4320727...@n4.nabble.com> wrote: > If 'idh' is the set of indices resulting from the 'split', then your > function would probably have to look like this: > > myfun <- function(x){ > H.scv <- Hscv(data[x, ], pil

Re: [R] converting a for loop into a foreach loop

2012-01-23 Thread jim holtman
If 'idh' is the set of indices resulting from the 'split', then your function would probably have to look like this: myfun <- function(x){ H.scv <- Hscv(data[x, ], pilot = "unconstr") KDE <- kde(data[x, ], H=H.scv, approx.cont=TRUE) } This is based on your original example where 'data' was the ob

Re: [R] converting a for loop into a foreach loop

2012-01-23 Thread kalee
Thanks Jim for your reply. I've split the dataset into indices but am now having problem with my function. The function I need to use is in two parts: > H.scv <- Hscv(idh, pilot = "unconstr") ## commands from the ks package > > KDE <- kde(idh, H=H.scv, approx.cont=TRUE) I've tried to write the

Re: [R] converting a for loop into a foreach loop

2012-01-19 Thread jim holtman
You may not need foreach if you use the power of R and vectorize your operations. Instead of going through the loops and extracting subsets at each iteration, use 'split' to either split the dataframe into the subsets, or faster, create a set of indices to access the subsets of data: Here is one