Package 'customiser'

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

Help Index


Create your .Rprofile from R Markdown

Description

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.

Usage

customiser(file, ..., quiet = FALSE)

Arguments

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. FALSE by default.

Details

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.

Value

Invisibly, a string with the location of the .Rprofile file being written to.

Examples

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"))

Example R markdown files

Description

Exclusively for testing and demonstration, the package comes with a few simple R Markdown files.

Usage

rmarkdown_simple()

rmarkdown_no_overwrite()

rmarkdown_allow_overwrite()

Value

Character path to the example file.

Examples

rmarkdown_simple()
rmarkdown_no_overwrite()
rmarkdown_allow_overwrite()