简体   繁体   中英

chart_Series: No plot when sourced from script

When I call chart_Series from a script I get a blank, white graphics device only. Example code:

Lines <- "2018-01-02;2683.73;2695.89;2682.36;2695.81
2018-01-03;2697.85;2714.37;2697.77;2713.06
2018-01-04;2719.31;2729.29;2719.07;2723.99
2018-01-05;2731.33;2743.45;2727.92;2743.15
2018-01-08;2742.67;2748.51;2737.60;2747.71
2018-01-09;2751.15;2759.14;2747.86;2751.29"

a <- as.xts (read.csv2.zoo (text = Lines,
    col.names = c("Date", "Open", "High", "Low", "Close"),
    header=F, stringsAsFactors = F, dec = ".", FUN = as.POSIXct))

chart_Series (a)

When I call "chart_Series (a)" on the R console it runs fine.

What's the issue with sourced chart_Series?

packageVersion("quantmod") [1] '0.4.13'

As authors of this package stated in their documentation, the function is highly experimental. Looking at their source code they are using their new new.replot() function and fill it with some environment parameters. Environment within source() function however is different from when the function is called directly and it looks like it causes problems in this case.

Here are some notes from github where they explain that they had a bug with tracing local variables. However they did not address the same issue with .plotEnv variable they are using in their function https://github.com/joshuaulrich/quantmod/commit/427e68a6c2f1997ce477f2bacd3ed54913b585fe

I would recommend to submit a bug report to the author of the package

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM