Title: | Use R Markdown to Write your "Rprofile" |
---|---|
Description: | A simple way to write ".Rprofile" code in an R Markdown file and have it knit to the correct location for your operating system. |
Authors: | James Laird-Smith [aut, cre, cph] |
Maintainer: | James Laird-Smith <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1.9000 |
Built: | 2024-11-05 04:42:45 UTC |
Source: | https://github.com/jameslairdsmith/customiser |
Mainly useful as the "knit:" parameter of an R Markdown file. A document with this option will have its R code made into the contents of the appropriate .Rprofile file for the user's operating system.
customiser(file, ..., quiet = FALSE)
customiser(file, ..., quiet = FALSE)
file |
Character. The R Markdown file from which to extract code. |
... |
For future extensions and must be empty. |
quiet |
Logical. Whether to silence the confirmation message.
|
The function always writes the .Rprofile to R's home directory as determined
by fs::path_home_r()
. If you wish to overwrite this behaviour, you can
set the "customiser.r_home" global option to the target directory of your
choosing.
Invisibly, a string with the location of the .Rprofile file being written to.
library(withr) my_rmarkdown_file <- rmarkdown_simple() tmp <- tempdir() with_options(list(customiser.r_home = tmp), { customiser(my_rmarkdown_file) }) file.exists(file.path(tmp, ".Rprofile"))
library(withr) my_rmarkdown_file <- rmarkdown_simple() tmp <- tempdir() with_options(list(customiser.r_home = tmp), { customiser(my_rmarkdown_file) }) file.exists(file.path(tmp, ".Rprofile"))
Exclusively for testing and demonstration, the package comes with a few simple R Markdown files.
rmarkdown_simple() rmarkdown_no_overwrite() rmarkdown_allow_overwrite()
rmarkdown_simple() rmarkdown_no_overwrite() rmarkdown_allow_overwrite()
Character path to the example file.
rmarkdown_simple() rmarkdown_no_overwrite() rmarkdown_allow_overwrite()
rmarkdown_simple() rmarkdown_no_overwrite() rmarkdown_allow_overwrite()