在脚本中运行ggplot,保存变量并调用print()。绘图窗口仍未显示。

时间:2015-07-07 21:53:59

标签: r ggplot2

我的脚本中有以下内容:

X <- as.numeric(colnames(sers$spectra))
Y <- sers$spectra[1, ]

require(ggplot2)
emptydf <- data.frame()
p <- ggplot(emptydf, aes(x=X, y=Y))
p <- p + geom_line()
print(p)

message("Press Return To Continue")
invisible(readLines("stdin", n=1))

当我执行此操作时,我看到:

$ Rscript analyze.R
Loading required package: pls

Attaching package: ‘pls’

The following object is masked from ‘package:stats’:

    loadings

Loading required package: ggplot2
Loading required package: methods
Don't know how to automatically pick scale for object of type AsIs. Defaulting to continuous
Don't know how to automatically pick scale for object of type AsIs. Defaulting to continuous
Press Return To Continue

我已经尝试在我的控制台中使用它,但它确实有效。我将ggplot()的输出保存到变量中并尝试在此处打印。

我需要最后两行,否则我的脚本将终止。当我执行此操作时,我看不到任何情节窗口。为什么?

0 个答案:

没有答案