Specify function parameters in do.call

Lets say that I have a function that retrieves data from Yahoo called Yahoo.Fetch, and I run do.call for a function that will:

do.call(merge.xts, lapply(list.of.tickers, Yahoo.Fetch)) 

The default will be all=TRUE in merge.xts , so how can I specify in do.call to have all=FALSE ? This is just an example, but I would like to know how to change and specify parameters in the apply, do.call, lapply functions.

+4
source share
1 answer

You can add it as a named value to an existing list with c() , which returns another list:

 do.call(merge.xts, c( lapply(list.of.tickers, Yahoo.Fetch), all=FALSE )) 

Or wrap the parameter with an anonymous helper function:

 do.call( function(x) merge.xts(x, all=FALSE), lapply(list.of.tickers, Yahoo.Fetch)) 
+10
source

Source: https://habr.com/ru/post/1497327/


All Articles