R/switch_to.R
switch_to_original.Rd
When there are several versions of a document (R script, R
Markdown or Quarto document), switch the main file to one of the saved
versions: original version, solution with the correction, or last saved
version. The save_as_original()
and save_as_solution()
functions are
used to create respectively the original and solution versions of the
document. These files have same name as the initial file but ending with
_original
, _solution
or _last_saved
., and starting with a dot .
.
They are thus "hidden" files. For R scripts, the extension is also changed
into .Rscript
for the original and solution versions.
switch_to_original(file = NULL, error = TRUE)
switch_to_solution(file = NULL, error = TRUE)
switch_to_last_saved(file = NULL, error = TRUE)
save_as_original(file = NULL)
save_as_solution(file = NULL)
The file to switch to a version. If not provided, the currently edited file in RStudio is used by default
In case the version does not exists, do we issue an error or not (no by default)
NULL
is returned invisibly. The functions are used for their
side-effect of switching document versions.