redo.if | R Documentation |
Basically executes an IF/ELSE statement to either re-run code (if the redo variable is TRUE) or return data saved in an RDS file (if the redo variable is FALSE).
redo.if( redo.var, save.file = NULL, code, force = FALSE, max.save.mb = 10, lf.dir = "Large_files" )
redo.var |
character; The redo variable name you want to reference. |
save.file |
character; The RDS file to which you want to save the results or from which you want to read prior results. If '.rds' is not at the end of the file, it will be appended. |
code |
The code (in curly brackets) you want to execute within the statement which should produce the object you want to return and save when the redo variables is TRUE. |
max.save.mb |
integer; the file size (in megabytes) at which a saved file will trigger a prompt to move it to the 'lf.dir' |
lf.dir |
character; the name of the directory to move files larger than 'max.save.mb' to. Default is "Large_files" |
chunk.names <- c("chunk1", "chunk2") assign.redo(chunk.names) toggle.redo("chunk1") if (redo$chunk1) { x <- rnorm(100) } else { x <- data(example_data1) } x <- redo.if("chunk1", save.file = "test_file.rds", {rnorm(50)})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.