Learn R Programming

misty (version 0.6.7)

script.copy: Save Copy of the Current Script in RStudio

Description

This function saves a copy of the current script in RStudio. By default, a folder called _R_Script_Archive will be created to save the copy of the current R script with the current date and time into the folder. Note that the current R script needs to have a file location before the script can be copied.

Usage

script.copy(file = NULL, folder = "_R_Script_Archive", create.folder = TRUE,
            time = TRUE, format = "%Y-%m-%d_%H%M", overwrite = TRUE,
            check = TRUE)

Arguments

file

a character string naming the file of the copy without the file extension ".R". By default, the file of the copy has the same name as the original file.

folder

a character string naming the folder in which the file of the copy is saved. If NULL, the file of the copy is saved in the same folder as the original file. By default, the file of the copy is saved into a folder called "_R_Script_Archive".

create.folder

logical: if TRUE (default), folder(s) specified in the file argument is created. If FALSE and the folder does not exist, then a error message is printed on the console.

time

logical: if TRUE (default), the current time is attached to the name of the file specified in the argument file.

format

a character string indicating the format if the POSIXct class resulting from the Sys.time function. The default setting provides a character string indicating the year, month, day, minutes, and seconds. See the help page of the format.POSIXct function.

overwrite

logical: if TRUE (default) an existing destination file is overwritten.

check

logical: if TRUE (default), argument specification is checked.

Author

Takuya Yanagida takuya.yanagida@univie.ac.at

References

Ushey, K., Allaire, J., Wickham, H., & Ritchie, G. (2023). rstudioapi: Safely access the RStudio API. R package version 0.15.0 https://CRAN.R-project.org/package=rstudioapi

See Also

script.new, script.close, script.open, script.save, setsource

Examples

Run this code
if (FALSE) {
# Example 1: Save copy current R script into the folder '_R_Script_Archive'
script.copy()

# Exmample 2: Save current R script as 'R_Script.R' into the folder 'Archive'
script.copy("R_Script", folder = "Archive", time = FALSE)
}

Run the code above in your browser using DataLab