Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R ggiraph-运行.R文件时没有打印_R_Plot_Ggiraph - Fatal编程技术网

R ggiraph-运行.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文

执行.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文件,然后生成一个
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" )