Title: | Spy on Your R Session |
---|---|
Description: | Conveniently log everything you type into the R console. Logs are are stored as tidy data frames which can then be analyzed using 'tidyverse' style tools. |
Authors: | Sean Kross [aut, cre] , Lucy D'Agostino McGowan [aut] , Jeff Leek [ldr] |
Maintainer: | Sean Kross <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.3 |
Built: | 2024-11-08 02:56:41 UTC |
Source: | https://github.com/jhudsl/matahari |
Create a matahari-esque data frame from a file.
dance_recital(code, evaluate = TRUE)
dance_recital(code, evaluate = TRUE)
code |
A string or the path to a file containing R code. |
evaluate |
Logical, indicating whether to evaluate the code, default is |
library(knitr) # Evaluate a string of R code kable(dance_recital("x <- 4; x *7")) ## |expr |value |error |output |warnings |messages | ## |:------|:-----|:-----|:------|:------------|:------------| ## |x <- 4 |4 |NULL | |character(0) |character(0) | ## |x * 7 |28 |NULL | |character(0) |character(0) | # Evaluate an R script. We have provided an R script for testing purposes. code_file <- system.file("test", "sample_code.R", package = "matahari") kable(dance_recital(code_file)[,1:3]) ## |expr |value |error | ## |:-------------------|:--------|:----------------------------------------| ## |4 + 4 |8 |NULL | ## |wow! |wow! |NULL | ## |mean(1:10) |5.5 |NULL | ## |stop("Error!") |NULL |list(message = "Error!", call = .f(...)) | ## |warning("Warning!") |Warning! |NULL | ## |message("Hello?") |NULL |NULL | ## |cat("Welcome!") |NULL |NULL |
library(knitr) # Evaluate a string of R code kable(dance_recital("x <- 4; x *7")) ## |expr |value |error |output |warnings |messages | ## |:------|:-----|:-----|:------|:------------|:------------| ## |x <- 4 |4 |NULL | |character(0) |character(0) | ## |x * 7 |28 |NULL | |character(0) |character(0) | # Evaluate an R script. We have provided an R script for testing purposes. code_file <- system.file("test", "sample_code.R", package = "matahari") kable(dance_recital(code_file)[,1:3]) ## |expr |value |error | ## |:-------------------|:--------|:----------------------------------------| ## |4 + 4 |8 |NULL | ## |wow! |wow! |NULL | ## |mean(1:10) |5.5 |NULL | ## |stop("Error!") |NULL |list(message = "Error!", call = .f(...)) | ## |warning("Warning!") |Warning! |NULL | ## |message("Hello?") |NULL |NULL | ## |cat("Welcome!") |NULL |NULL |
Remove your logging history.
dance_remove()
dance_remove()
Either TRUE
if the log was removed or FALSE
if the log
does not exist (invisibly).
## Not run: library(knitr) # Start recording dance_start(value = TRUE) # Execute some expressions "Hello!" 4 + 4 # Stop recording dance_stop() # Access log of your session kable(dance_tbl()[3:4, 1:5]) ## |expr |value |path |contents |selection | ## |:------|:------|:----|:--------|:---------| ## |Hello! |Hello! |NA |NA |NA | ## |4 + 4 |8 |NA |NA |NA | # Deletes the lgo of your session dance_remove() # With no log, dance_tbl() returns NULL invisibly. withVisible(dance_tbl()) ## $value ## NULL ## ## $visible ## FALSE ## End(Not run)
## Not run: library(knitr) # Start recording dance_start(value = TRUE) # Execute some expressions "Hello!" 4 + 4 # Stop recording dance_stop() # Access log of your session kable(dance_tbl()[3:4, 1:5]) ## |expr |value |path |contents |selection | ## |:------|:------|:----|:--------|:---------| ## |Hello! |Hello! |NA |NA |NA | ## |4 + 4 |8 |NA |NA |NA | # Deletes the lgo of your session dance_remove() # With no log, dance_tbl() returns NULL invisibly. withVisible(dance_tbl()) ## $value ## NULL ## ## $visible ## FALSE ## End(Not run)
Copy the log to your clipboard.
dance_report(...)
dance_report(...)
... |
Developer options. |
## Not run: # Start recording dance_start(value = TRUE) # Execute some expressions "Hello!" 4 + 4 # Stop recording dance_stop() # Assign a base64 encoded tibble of your log to a variable report_code <- dance_report() substr(report_code, 1, 10) ## "WAoAAAADAA" nchar(report_code) ## 397432 ## End(Not run)
## Not run: # Start recording dance_start(value = TRUE) # Execute some expressions "Hello!" 4 + 4 # Stop recording dance_stop() # Assign a base64 encoded tibble of your log to a variable report_code <- dance_report() substr(report_code, 1, 10) ## "WAoAAAADAA" nchar(report_code) ## 397432 ## End(Not run)
Save the log as an rds file.
dance_save(path)
dance_save(path)
path |
The path to the rds file. |
## Not run: # Start recording dance_start(value = TRUE) # Execute some expressions "Hello!" 4 + 4 # Stop recording dance_stop() # Save your log locally dance_save("session.rds") ## End(Not run)
## Not run: # Start recording dance_start(value = TRUE) # Execute some expressions "Hello!" 4 + 4 # Stop recording dance_stop() # Save your log locally dance_save("session.rds") ## End(Not run)
Start logging your R console activity. If you're using RStudio the contents of your current editor tab will also be tracked. All logging takes place when R code is executed in the R console.
dance_start( expr = TRUE, value = FALSE, path = FALSE, contents = FALSE, selection = FALSE )
dance_start( expr = TRUE, value = FALSE, path = FALSE, contents = FALSE, selection = FALSE )
expr |
The R expressions typed into the R console will be logged unless
this is set to |
value |
Values that are computed on the R console will be logged unless
this is set to |
path |
The path to the file in focus on the RStudio editor will be logged
unless this is set to |
contents |
The file contents of the RStudio editor tab in focus will be
logged unless this is set to |
selection |
The text that is highlighted in the RStudio editor tab in
focus will be logged unless this is set to |
## Not run: # Begin recording your R session. dance_start() # Each of the following expressions adds a row to the tibble that tracks # the execution of your R code. "Hello!" 4 + 4 x <- 7 x^2 rm(x) x # This stops recording your R session. dance_stop() ## End(Not run)
## Not run: # Begin recording your R session. dance_start() # Each of the following expressions adds a row to the tibble that tracks # the execution of your R code. "Hello!" 4 + 4 x <- 7 x^2 rm(x) x # This stops recording your R session. dance_stop() ## End(Not run)
Pause the current logging session.
dance_stop()
dance_stop()
TRUE
if logging was taking place, otherwise FALSE
(invisibly).
## Not run: # Begin recording your R session. dance_start() # Each expression adds a row to the tibble that tracks the execution of # your R code. x <- 7 x * 4 # This stops recording your R session. dance_stop() ## End(Not run)
## Not run: # Begin recording your R session. dance_start() # Each expression adds a row to the tibble that tracks the execution of # your R code. x <- 7 x * 4 # This stops recording your R session. dance_stop() ## End(Not run)
Get the log as a tibble
dance_tbl()
dance_tbl()
Either a tibble::tibble()
containing your logged history or NULL
.
if there is no log.
## Not run: library(knitr) # Start recording dance_start(value = TRUE) # Execute some expressions "Hello!" 4 + 4 # Stop recording dance_stop() # Access log of your session dance_tbl() # Display the log nicely kable(dance_tbl()[3:4, 1:5]) ## |expr |value |path |contents |selection | ## |:------|:------|:----|:--------|:---------| ## |Hello! |Hello! |NA |NA |NA | ## |4 + 4 |8 |NA |NA |NA | ## End(Not run)
## Not run: library(knitr) # Start recording dance_start(value = TRUE) # Execute some expressions "Hello!" 4 + 4 # Stop recording dance_stop() # Access log of your session dance_tbl() # Display the log nicely kable(dance_tbl()[3:4, 1:5]) ## |expr |value |path |contents |selection | ## |:------|:------|:----|:--------|:---------| ## |Hello! |Hello! |NA |NA |NA | ## |4 + 4 |8 |NA |NA |NA | ## End(Not run)