在Windows 8系统上使用RStudio给我以下错误消息:

Error in savePlot(filename = "123", type = c("png"), device = dev.cur()) :
  can only copy from 'windows' devices

如果我在savePlot之前的行中写windows(),错误消息将消失,但情节为“空”。
如果我使用R代替RStudio,则不存在该问题。

除了“不使用RStudio”之外,还有其他解决方案吗?
最好的祝福

编辑:
这是更多原始代码:
#--------------create plot

x <- df$Year
y <- df$Index1970
par(family="serif", font=1, cex=1)
xrange <- range(x, na.rm=TRUE)
yrange <- range(y, na.rm=TRUE)
plot(xrange, yrange, type="n", xlab="Year",
    ylab="Price index, 1970=100" )
lines(x, y, col="black", lwd=3)
title("Belgium Property Prices from 1970-2013")
grid(nx = NULL, ny = NULL, col = "lightgray", lty = "dotted",
     lwd = par("lwd"), equilogs = TRUE)
savePlot(filename="D:/...RPlots/Belgium_Prices_from_1970-2013",
         type=c("wmf"),
         device=dev.cur(), #type=c("wmf", "png", "jpeg", "jpg", "bmp", "ps", "pdf")
         restoreConsole = TRUE)

我在哪里以及如何在此处分别使用png和win.metafile函数?
它可以在R中使用,但不能在RStudio中使用...

最佳答案

您可以使用png函数。例如:

png(filename = "testPlot.png", width = 480, height = 480)
plot(1:10, type = 'l')
dev.off()

filename中,您应该定义绘图的路径。

08-27 19:53
查看更多