Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R equivalent of bash's set -x; echo all commands being executed?

Tags:

r

In bash, if you enable set -x, the script will echo the evaluated form of all commands to the stderr logs. In tcsh, this same is accomplished with set echo. Is there something similar for R? It would help debugging if I had more verbose output of what the script commands look like as they are being run, without having to manually print or cat every single one.

like image 904
user5359531 Avatar asked Jul 11 '16 17:07

user5359531


People also ask

What is the use of echo command in shell script?

Echo is also particularly useful for showing the values of environmental variables, which tell the shell how to behave as a user works at the command line or in scripts. touch is going to be the easiest way to create new files, but it can also be used to change timestamps on files and/or directories.

How do I execute a shell script in Bash?

A bash script can contain any number of normal shell commands: [andrew@pc01 ~ ] $ echo "ls && touch file && ls" > ex.sh A shell script can be executed with the source command or the sh command: [andrew@pc01 ~ ] $ source ex.sh ...

What are the different shells in Linux?

Other common ones include zsh, csh, fish, and more. Play around with different shells and find one that's right for you, but be aware that this tutorial contains bash shell commands only and not everything listed here (maybe none of it) will be applicable to shells other than bash.

What are the different types of Bash operators?

Different types of operators exist in Bash to perform various operations using bash script. Some common groups of bash operators are arithmetic operators, comparison operators, bit-wise operators, logical operators, string operators, and file operators. The most used 74 bash operators are explained in this article with examples.


1 Answers

This answer assumes command-line.

The script is:

1 + 1

3 + 3

100 + 100

This it running:

$ Rscript -e 'source("/tmp/run.R", echo=TRUE)'
## 
## > 1 + 1
## [1] 2
## 
## > 3 + 3
## [1] 6
## 
## > 100 + 100
## [1] 200

It shld be trivial to make a wrapper script for that. littler might even have an option like this.

like image 97
hrbrmstr Avatar answered Oct 15 '22 14:10

hrbrmstr