[R] mapply, quantmod::chart_Series, MoreArgs error with chart_pars(), chart_theme()

Anuj Goyal @nuj@goy@| @end|ng |rom gm@||@com
Sat Jul 27 19:47:11 CEST 2019


R version 3.6.0 (2019-04-26) on Mac 10.14.5

What is the proper way to pass chart_pars() as well as chart_theme()
into MoreArgs for use in quantmod::chart_Series?

p.txt
=======
s,n
ABBV,AbbVie
BMY,Bristol

sof.r
=======
# R --silent --vanilla < sof.r
library(quantmod)
options("getSymbols.warning4.0"=FALSE)
options("getSymbols.yahoo.warning"=FALSE)

# setup chart params
cp <- chart_pars()
cp$cex=0.55
cp$mar=c(1,1,0,0) # B,L,T,R

# setup chart theme
ct <- chart_theme()
ct$grid.ticks.lwd=1

# read values into vectors
csv <- read.csv("p.txt", stringsAsFactors = FALSE)
symVec <- getSymbols(as.vector(csv$s))
infoVec <- mapply(paste, csv$s, csv$n, sep=": ") # eg. SYM: Name
cpVec = rep(cp, times=nrow(csv))

# create PDF
pdf(file = "p.pdf")
par(mfrow = c( 5, 4 ) )
mapply (chart_Series, mget(symVec), name=infoVec, NULL, NULL, NULL,
MoreArgs=cp, MoreArgs=ct)
dev.off()

Error
======
Error in mapply(chart_Series, mget(symVec), name = infoVec, NULL,
NULL, : formal argument "MoreArgs" matched by multiple actual
arguments
Execution halted


>>> I also tried this.

mapply (chart_Series, mget(symVec), name=infoVec, NULL, NULL, NULL,
MoreArgs = list(quote('pars=cp')))

Error in mapply(chart_Series, mget(symVec), name = infoVec, NULL,
NULL, : zero-length inputs cannot be mixed with those of non-zero
length Execution halted



More information about the R-help mailing list