running Rscript containing ggplot from linux command line through Xterm

。_饼干妹妹 提交于 2019-12-11 14:28:23

问题


I am using Xterm on a linux server so I can quickly plot data without transferring the files to my local machine. I have a R script that uses ggplot(), not inside a function. When I open R through Xterm I use these commands to run the script and the plot windows works fine in Xterm

commandArgs <- function(...) 'plotname'
source('graph.r', print.eval=TRUE))

However when I try from bash with Rscript, such as

Rscript graph.r plotname

The script runs but the plot window doesn't open. I know this is a ggplot problem because if I just use plot() inside the script the plot window works. I have tried several suggestions from this question.

ggplot's qplot does not execute on sourcing

And also tried to create a bash script starting with #!/usr/bin/env Rscript, nothing seems to work.

Is there a solution? I need to pass an argument to the R function

来源:https://stackoverflow.com/questions/59181206/running-rscript-containing-ggplot-from-linux-command-line-through-xterm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!