I am wondering if there is a way to specify the package, e.g. with ::
when making a call to a function. The following example shows that the do.call()
only works when the package is loaded, and the function is named directly:
# doesn't work
do.call("pals::brewer.spectral", args = list(n=10))
# Error in `pals::brewer.spectral`(n = 10) : could not find function "pals::brewer.spectral"
# works when package is loaded
library(pals)
do.call("brewer.spectral", args = list(n=10))
# [1] "#9E0142" "#D53E4F" "#F46D43" "#FDAE61" "#FEE08B" "#E6F598" "#ABDDA4" "#66C2A5" "#3288BD" "#5E4FA2"