Execute R commands in R environment with gnome-terminal

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.

I found a similar Q in the below link,

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

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

But the solution discussed in the thread (Rscript) doesn't work for me.

I'm trying to run the below code,

gnome-terminal -- /bin/sh -c 'R;Sys.getenv("PATH")'

But I'm getting an error when I use (Sys.getenv("PATH")) after R command. I guess it is due to /bin/sh.

gnome-terminal -- /bin/sh -c 'R' 

When I run the above code, it opens another terminal and invokes R environment successfully.

Can someone advise how to execute multiple R commands in gnome-terminal.

Use Rscript

2 Likes

How to use R script to just get Path inside the R environment

I tried your code,

sgpengcs001:sviswan1:132 > /bin/sh -c 'R;Sys.getenv("PATH");'
/bin/sh: -c: line 0: syntax error near unexpected token `"PATH"'
/bin/sh: -c: line 0: `R;Sys.getenv("PATH");'

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.