save_code: Save generated code to a file

Description Usage Arguments Examples

View source: R/save_code.r

Description

Helper function that saves generated R code to a file. Does not overwrite existing files unless overwrite is explicitly set to TRUE.

Usage

1
save_code(code, file, overwrite = FALSE)

Arguments

code

character string with R code.

file

character string of the filename to be saved.

overwrite

whether the existing files should be overwritten.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
# Create random data.
data <- data.frame(x = rnorm(100), y = rnorm(100))

# Generate R code.
code <- semproducible(data, formula="y ~ x")

# Save R code to file.
save_code(code, "create_data.r")

# Save again, but the file exists so overwrite=TRUE is necessary.
save_code(code, "create_data.r", overwrite = TRUE)

## End(Not run)

peterdalle/semproducible documentation built on Sept. 4, 2020, 8:02 a.m.