In order : launch new terminal, launch R environment in the new terminal, execute commands in R environment

被刻印的时光 ゝ 提交于 2021-02-11 07:34:57

问题


I would like a shell script that launches a new terminal, opens the R environment in the terminal and executes commands in the R environment of the new terminal. Here's what I did which is not working :

#!/bin/sh
for i in $(seq 25)
do
gnome-terminal -x sh "R; source('source.r'); function($i)"
done

Where, function() is an r function in the file "source.r"

Please help.

N.B. I don't want to launch the program using the command "Rscript"

EDIT 1 : I don't want to use the command Rscript because the execution halts after sometime (don't know why). In an R environment the script works fine though. Here's what I tried with the command Rscript :

#!/bin/sh
for i in $(seq 25)
do
gnome-terminal -e "Rscript script.r $i"
done

EDIT 2 : I found the reason why the script execution halted with the command Rscript. It was a bug in the code. Now I can make things work with what I did in EDIT 1. Would be nice to know if things can be made to work by not using Rscript i.e. launching R in different terminals and executing commands in each terminal from the shell script.

来源:https://stackoverflow.com/questions/37434795/in-order-launch-new-terminal-launch-r-environment-in-the-new-terminal-execut

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