The goal of {echo}
is to provide a function for evaluating and logging
a script.
Install {echo}
from CRAN with:
install.packages("echo")
Alternatively, you can install the development version of {echo}
GitHub with:
# install.packages("devtools")
devtools::install_github("jmbarbone/echo")
echo()
allows you to print
library(echo)
try(echo(
expr = {
print(1 + 1)
df <- data.frame(a = 1:5, b = letters[1:5])
print(df)
message("hello!")
warning("hello!")
stop("error here")
},
level = 0
), silent = TRUE)
#> [2023-05-22 09:58:20] [EXP] print(1 + 1)
#> [2023-05-22 09:58:20] [OUT] #> [1] 2
#> [2023-05-22 09:58:20] [EXP] df <- data.frame(a = 1:5, b = letters[1:5])
#> [2023-05-22 09:58:20] [EXP] print(df)
#> [2023-05-22 09:58:20] [OUT] #> a b
#> [2023-05-22 09:58:20] [OUT] #> 1 1 a
#> [2023-05-22 09:58:20] [OUT] #> 2 2 b
#> [2023-05-22 09:58:20] [OUT] #> 3 3 c
#> [2023-05-22 09:58:20] [OUT] #> 4 4 d
#> [2023-05-22 09:58:20] [OUT] #> 5 5 e
#> [2023-05-22 09:58:20] [EXP] message("hello!")
#> [2023-05-22 09:58:20] [MSG] #> hello!
#> [2023-05-22 09:58:20] [EXP] warning("hello!")
#> [2023-05-22 09:58:20] [WRN] #> hello!
#> [2023-05-22 09:58:20] [EXP] stop("error here")
#> [2023-05-22 09:58:20] [ERR] #> error here