Alright, I found the solution on my own at least it seems that way.  Here is
what I discovered for future reference in the R-help archive.

The issue with parLapply comes in with the docall function in parLapply,

> parLapply
function(cl, x, fun, ...){
 docall(c, clusterApply(cl, splitList(x, length(cl)), lapply,
    fun, ...))
}

What I found to be happening is although I had done nothing to assign a
value to c (i.e. c <- something), c was altered to be a numerical value.

Taking the docall function out of parLapply and modifying it to the
following allowed it to function properly

docall("c",clusterApply(cl,splitList(x,length(cl)),lapply,fun,...))

docall will find the right function like this and it works appropriately as
well.  I don't know how exactly that c, without quotes, was modified to
begin with, since my code showed nothing visibly modifying it.  Regardless,
this is what worked for me.

A



On Thu, Dec 2, 2010 at 4:36 PM, Adrienne Wootten <amwoo...@ncsu.edu> wrote:

> Hello everybody,
>
> I've got a bit of a problem with parLapply that's left me scratching my
> head today.  I've tried this in R 2.11 and the 23 bit Revolution R
> Enterprise and gotten the same result, OS in question is Windows XP, the
> package involved is the snow package.
>
> I've got a list of 20 rain/no rain (1/0) situations for these two stations
> i and j, all the items in this list look like this, each of these have a
> different order:
>
> > setin[[20]]
>    ri_1 rj_1
> 29    0    0
> 15    0    0
> 3     1    0
> 31    0    0
> 4     0    0
> 1     1    1
> 18    1    1
> 21    0    0
> 27    0    0
> 24    0    0
> 6     0    1
> 9     1    1
> 5     0    0
> 30    0    0
> 25    0    0
> 28    0    0
> 19    1    1
> 8     0    0
> 17    1    1
> 12    0    0
> 10    0    0
> 22    1    1
> 23    0    0
> 7     1    1
> 14    0    0
> 26    0    0
> 13    0    0
> 2     0    1
> 11    1    1
> 20    1    1
> 16    1    1
>
> What I'm trying to do is to apply the same function I crafted to all the
> items in the list with parLapply.  I'm using this instead of apply since it
> allows me to test using parallel running R, and because it runs faster than
> lapply.
>
> M_set <-
> parLapply(cl,setin,M.set.find,month=month,n1=n1,n2=n2,MC_1st_obs2=MC_1st_obs2)
>
> using this it gives me the follow error:
>
> Error in do.call("fun", lapply(args, enquote)) :
>   could not find function "fun"
>
> but, this works correctly when I just use lapply (it's just a bit slower
> than I need it to be).  Also, I know that the clusterCall function works
> fine with my homemade function because all the nodes of the cluster return
> the appropriate results when I try this:
>
>
> clusterCall(cl,M.set.find,setin=setin[[1]],month=month,n1=n1,n2=n2,MC_1st_obs2=MC_1st_obs2)
>
> but that will only let me do this calculation one at a time.
>
> I perused the earlier post about this error, and that doesn't work for me,
> I don't do anything anywhere in my code to mess with "c".  I also know that
> my code is producing the rest of the required parts for the function
> correctly.
>
> I wish I could provide more on what's happened, but the code involved is
> somewhat extensive.  Any ideas all of you have would be wonderful.
>
> Thanks in advance!
>
> A
> --
> Adrienne Wootten
> Graduate Research Assistant
> State Climate Office of North Carolina
> Department of Marine, Earth and Atmospheric Sciences
> North Carolina State University
>
>


-- 
Adrienne Wootten
Graduate Research Assistant
State Climate Office of North Carolina
Department of Marine, Earth and Atmospheric Sciences
North Carolina State University

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to