[R] Change Function based on ifelse() condtion

Duncan Murdoch murdoch.duncan at gmail.com
Sun Mar 4 17:04:18 CET 2018

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 = 1, these 2 functions are essentially same,
> however I am looking for more general way to control them within
> ifelse() constion
> Can someone please help me how can I use them within ifelse() condition.

Don't.  ifelse() usually evaluates *both* the true and false values, and 
then selects entries from each.  Just use an if statement.

Duncan Murdoch

More information about the R-help mailing list