1

Using Rstudio (Version 1.0.143) under Ubuntu (16.04), if I add system("echo 'Hello world'") to my /usr/lib/R/etc/Rprofile.site file, I have no Hello world message displayed in R studio at startup.
If I start R from the terminal I have the Hello world message.

It seems that R studio ignores the system commands from Rprofile.site (idem from the .Rprofile file in the home directory)

Is it possible to enable system commands executions or is there a good reason to avoid this behavior ?

Gilles San Martin
  • 4,224
  • 1
  • 18
  • 31

1 Answers1

2

For short, RStudio doesn't source Rprofile.site file at all. (I use Ubuntu 17.04 and compile R-3.4.1 myself)

test Rprofile.site

To simply the question, you can use x=1 rather system("echo 'Hello world'") in the Rprofile.site file. Then you open RStudio:

> x
Error: object 'x' not found

That tells you whether RStudio ignores the system() commands in Rprofile.site or R studio ignores the entire Rprofile.site file.

test system()

If you find that your RStudio source theRprofile.site file instead. You can try system("echo haha > x") or system2('echo', 'haha', stdout = T) -> x.

That tells you whether RStudio ignores the system() commands or you can't see the message due to other reasons.

what RStudio says

Finally, see https://support.rstudio.com/hc/en-us/community/posts/200643758-Rprofile-site-

We don't actually implement the code for sourcing Rprofile.site (R does)

by Ian Pylvainen, Support Engineer at RStudio, Inc.

Zhuoer Dong
  • 629
  • 4
  • 11
  • In my configuration Rstudio seems to source everything from Rprofile.site but not the `system` commands. If I add `x=1` in this file the object is well available in Rstudio. `cat("Hello world")` prints also the message. See also [this question](https://stackoverflow.com/questions/45119432/more-meaningfull-window-title-for-rstudio) where we hack RStudio window title to make it more informative using `Rprofile.site`. – Gilles San Martin Jul 20 '17 at 20:33
  • That's very interesting. You may try what I add. – Zhuoer Dong Jul 21 '17 at 05:41
  • Clever idea ! Indeed the x file is created on the disc with `system("echo haha > x")`. So the system function is indeed executed but the output is not visible in the RStudio R console. I missed that because the system command I wanted to execute try to manipulate the RStudio window title but from within the Rprofile.site it is executed just before the RStudio windows is present ! But I found another way. – Gilles San Martin Jul 21 '17 at 20:25
  • Congratulations on your success! – Zhuoer Dong Jul 22 '17 at 12:12
  • url link is broken?! – Matifou May 08 '23 at 17:27