问题描述
以下数据可以是tibble
或data.table
:
datetime volume
<dttm> <dbl>
2020-08-25 09:30:00.000 0
2020-08-25 09:30:12.000 107
2020-08-25 09:30:50.000 221
2020-08-25 09:30:50.000 132
2020-08-25 09:30:50.000 148
2020-08-25 09:30:50.000 100
2020-08-25 09:30:50.000 100
2020-08-25 09:30:58.000 100
2020-08-25 09:31:56.000 157
2020-08-25 09:32:36.000 288
2020-08-25 09:32:36.000 100
2020-08-25 09:33:10.000 235
2020-08-25 09:33:23.000 182
2020-08-25 09:33:44.000 218
2020-08-25 09:33:44.000 179
2020-08-25 09:34:18.000 318
2020-08-25 09:34:27.000 101
2020-08-25 09:34:27.000 157
2020-08-25 09:34:27.000 200
2020-08-25 09:34:27.000 114
我已将上述数据转换为xts
对象,并希望从Rscript
调用绘图功能作为命令行实用程序。
这是我将数据转换为xts
的方式:
data %>% as.xts() -> testdata1
data %>% as.xts() -> testdata2
identical(testdata1,testdata2)
# output: TRUE
# first option
x11() # linux calls x11()
plot(x = data,observation.based = TRUE,major.ticks = "seconds",main = "Test Plot")
prompt <- "press any key to close the plot"
capture <- tcltk::tk_messageBox(message = prompt)
# second option
png("test.png")
plot(x = data,main = "Test Plot")
dev.off()
browseURL("test.png)
以上两种方法均不适用于xts
对象绘图。它适用于普通的data.frame
,data.table
和ggplot
。
有人尝试从命令行将xts
绘制到新设备上吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)