6 Using R and Python in the shell
6.1 R
Running R in the shell bring slightly different concerns from running R interactively - which is likely what most R users are used to.
There are a few extra quirks and considerations to running R in the shell, some of which are listed below.
6.1.1 Executing scripts
If you are intending to run an R script in the shell, the following line of text should be at the top of your script:
#!/usr/bin/env Rscript
6.1.2 Rscript vs R -f
What is the difference?
6.1.3 Logging methods
Base R’s sink()
function
The logging
and logger
packages.
6.1.4 A note on developing R packages
When writing functions as part of an R package, it could be useful to keep in mind that some users might not be using your package interactively, but through the shell.
There is no difference in functionality here, but feedback your package provides, say through print()
(discouraged), message()
/warning()
/stop()
, or cli::cat_*()
functions, behave slightly differently.