Reputation: 317
Lets say I have a function that fetches data from Yahoo called Yahoo.Fetch, and I run a do.call on the function, which would be:
do.call(merge.xts, lapply(list.of.tickers, Yahoo.Fetch))
The default would have all=TRUE
in merge.xts
, so how would I be able to specify in a do.call to have all=FALSE
? This is just an example, but I would like to know how to change and specify parameters in apply, do.call, lapply functions.
Upvotes: 8
Views: 5564
Reputation: 263481
You can add it as a named value to the existing list with c()
which returns another list:
do.call(merge.xts, c( lapply(list.of.tickers, Yahoo.Fetch), all=FALSE ))
This is because the c
function preserves the “list” class.
Or wrap the parameter in with an anonymous helper function:
do.call( function(x) merge.xts(x, all=FALSE),
lapply(list.of.tickers, Yahoo.Fetch))
Upvotes: 16