Displaying 10 results from an estimated 10 matches for "lapply_me".
Did you mean:
apply_mc
2018 Mar 04
3
Change Function based on ifelse() condtion
Below is my full implementation (tried to make it simple as for demonstration)
Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) {
if (Apply_MC) {
return(mclapply(X, FUN, ...))
} else {
if (any(names(list(...)) == 'mc.cores')) {
myList = list(...)[!names(list(...)) %in% 'mc.cores']
}
return(lapply(X, FUN, myList))
}
}
Lapply_me(as.list(1:4), function(xx) {...
2018 Mar 04
0
Change Function based on ifelse() condtion
...works for Apply_MC=TRUE is that in that case you call
mclapply(X,FUN,...) and
the mclapply() function strips off the mc.cores argument from the "..."
list before calling FUN, so FUN is being called with zero arguments,
exactly as it is declared.
A quick workaround is to change the line
Lapply_me(as.list(1:4), function(xx) {
to
Lapply_me(as.list(1:4), function(xx,dummyList) {
HTH,
Eric
On Sun, Mar 4, 2018 at 7:21 PM, Christofer Bogaso <
bogaso.christofer at gmail.com> wrote:
> Below is my full implementation (tried to make it simple as for
> demonstration)
>
> Lapply...
2018 Mar 04
2
Change Function based on ifelse() condtion
My modified function looks below :
Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) {
if (Apply_MC) {
return(mclapply(X, FUN, ...))
} else {
if (any(names(list(...)) == 'mc.cores')) {
myList = list(...)[!names(list(...)) %in% 'mc.cores']
}
return(lapply(X, FUN, myList))
}
}
Here, I am not passing ... anymore rath...
2018 Mar 04
0
Change Function based on ifelse() condtion
That's fine. The issue is how you called Lapply_me(). What did you pass as
the argument to FUN?
And if you did not pass anything that how is FUN declared?
You have not shown that in your email.
On Sun, Mar 4, 2018 at 7:11 PM, Christofer Bogaso <
bogaso.christofer at gmail.com> wrote:
> My modified function looks below :
>
> Lapp...
2018 Mar 04
2
Change Function based on ifelse() condtion
...>
> HTH,
> Eric
>
> On Sun, Mar 4, 2018 at 6:38 PM, Christofer Bogaso
> <bogaso.christofer at gmail.com> wrote:
>>
>> Hi,
>>
>> As an example, I want to create below kind of custom Function which
>> either be mclapply pr lapply
>>
>> Lapply_me = function(X = X, FUN = FUN, ..., Apply_MC = FALSE) {
>> if (Apply_MC) {
>> return(mclapply(X, FUN, ...))
>> } else {
>> if (any(names(list(...)) == 'mc.cores')) {
>> list(...) = list(...)[!names(list(...)) %in% 'mc.cores']
>> }
>> return(la...
2018 Mar 04
2
Change Function based on ifelse() condtion
Hi,
As an example, I want to create below kind of custom Function which
either be mclapply pr lapply
Lapply_me = function(X = X, FUN = FUN, ..., Apply_MC = FALSE) {
if (Apply_MC) {
return(mclapply(X, FUN, ...))
} else {
if (any(names(list(...)) == 'mc.cores')) {
list(...) = list(...)[!names(list(...)) %in% 'mc.cores']
}
return(lapply(X, FUN, ...))
}
}
However when Apply_MC = FALSE it genera...
2018 Mar 04
0
Change Function based on ifelse() condtion
...n, Mar 4, 2018 at 6:38 PM, Christofer Bogaso
> > <bogaso.christofer at gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> As an example, I want to create below kind of custom Function which
> >> either be mclapply pr lapply
> >>
> >> Lapply_me = function(X = X, FUN = FUN, ..., Apply_MC = FALSE) {
> >> if (Apply_MC) {
> >> return(mclapply(X, FUN, ...))
> >> } else {
> >> if (any(names(list(...)) == 'mc.cores')) {
> >> list(...) = list(...)[!names(list(...)) %in% 'mc.cores']
>...
2018 Mar 04
0
Change Function based on ifelse() condtion
...<- list(...)[!names(list(...)) %in% 'mc.cores']
HTH,
Eric
On Sun, Mar 4, 2018 at 6:38 PM, Christofer Bogaso <
bogaso.christofer at gmail.com> wrote:
> Hi,
>
> As an example, I want to create below kind of custom Function which
> either be mclapply pr lapply
>
> Lapply_me = function(X = X, FUN = FUN, ..., Apply_MC = FALSE) {
> if (Apply_MC) {
> return(mclapply(X, FUN, ...))
> } else {
> if (any(names(list(...)) == 'mc.cores')) {
> list(...) = list(...)[!names(list(...)) %in% 'mc.cores']
> }
> return(lapply(X, FUN, ...))
> }
&g...
2018 Mar 04
2
Change Function based on ifelse() condtion
Hi again,
I am looking for some way to alternately use 2 related functions,
based on some ifelse() condition.
For example, I have 2 functions mclapply() and lapply()
However, mclapply() function has one extra parameter 'mc.cores' which
lapply doesnt not have.
I know when mc.cores = 1, these 2 functions are essentially same,
however I am looking for more general way to control them
2018 Mar 04
0
Change Function based on ifelse() condtion
On 04/03/2018 10:39 AM, Christofer Bogaso wrote:
> Hi again,
>
> I am looking for some way to alternately use 2 related functions,
> based on some ifelse() condition.
>
> For example, I have 2 functions mclapply() and lapply()
>
> However, mclapply() function has one extra parameter 'mc.cores' which
> lapply doesnt not have.
>
> I know when mc.cores =