R ggiraph-运行.R文件时没有打印
执行.R文件时如何获取图形?文件(R ggiraph-运行.R文件时没有打印,r,plot,ggiraph,R,Plot,Ggiraph,执行.R文件时如何获取图形?文件(test.r)如下所示: library(ggplot2) library(ggiraph) gg <- ggplot(data = mtcars, aes(x = mpg, y = wt, color = factor(cyl))) gg1 <- gg + geom_point_interactive(aes(tooltip = gear), size = 5) ggiraph(code = print(gg1)) R生成一个临时的.html文
test.r
)如下所示:
library(ggplot2)
library(ggiraph)
gg <- ggplot(data = mtcars, aes(x = mpg, y = wt, color = factor(cyl)))
gg1 <- gg + geom_point_interactive(aes(tooltip = gear), size = 5)
ggiraph(code = print(gg1))
R
生成一个临时的.html文件,然后生成一个gvfs open
进程来查看该文件(这将打开Firefox)。当您从命令行运行脚本时,R
退出并在Firefox进程有机会完全加载之前清理其临时文件。您可以通过以下操作看到这一点
$ R -q --interactive < test.R
> library(ggplot2)
> library(ggiraph)
> gg <- ggplot(data = mtcars, aes(x = mpg, y = wt, color = factor(cyl)))
> gg1 <- gg + geom_point_interactive(aes(tooltip = gear), size = 5)
> ggiraph(code = print(gg1))
Save workspace image? [y/n/c]:
gvfs-open: /tmp/RtmpPxtiZi/viewhtml3814550ff070/index.html: error opening location:
Error when getting information for file '/tmp/RtmpPxtiZi/viewhtml3814550ff070/index.html': No such file or directory
谢谢,您的第二个解决方案非常有效!由于一些小错误,我还安装了带有“sudo apt get install PANDOC”的PANDOC
R version 3.2.3 (2015-12-10)
x86_64-pc-linux-gnu
$ R -q --interactive < test.R
> library(ggplot2)
> library(ggiraph)
> gg <- ggplot(data = mtcars, aes(x = mpg, y = wt, color = factor(cyl)))
> gg1 <- gg + geom_point_interactive(aes(tooltip = gear), size = 5)
> ggiraph(code = print(gg1))
Save workspace image? [y/n/c]:
gvfs-open: /tmp/RtmpPxtiZi/viewhtml3814550ff070/index.html: error opening location:
Error when getting information for file '/tmp/RtmpPxtiZi/viewhtml3814550ff070/index.html': No such file or directory
myplot <- ggiraph(code = print(gg1))
htmlwidgets::saveWidget( myplot, "test.html" )
browseURL( "test.html" )