Skip to contents

Configures a project so that knitr and Quarto renders started from it use timeknit, without touching ~/.Rprofile or the site-wide profiles.

Usage

use_timeknit_project(path = ".")

remove_timeknit_project(path = ".")

Arguments

path

The project root, or any directory inside it. The root is the nearest directory at or above path containing _quarto.yml, an .Rproj file, DESCRIPTION, or .git, falling back to path itself.

Value

The project root, invisibly.

Details

use_timeknit_project() makes these changes at the project root:

  • Adds a managed block to the project's .Rprofile, creating the file if needed, that calls use_timeknit(). This covers R sessions started in the project, rmarkdown::render() and knitr::knit() from those sessions, and Quarto renders of documents in the project root. When the file is created from scratch the block also sources ~/.Rprofile first, because a project .Rprofile otherwise replaces it.

  • In a Quarto project (one with _quarto.yml), also writes a .timeknit.Rprofile and points R_PROFILE_USER at it from _environment.local. Quarto starts R in each document's own directory, where the project .Rprofile is not read, so this is what reaches documents in subdirectories. The profile loads whatever profile R would otherwise have used and then activates timeknit. _environment.local holds an absolute path, so in a git repository it is added to .gitignore.

Existing R_PROFILE_USER assignments in _environment.local are saved as comments and restored on removal. The generated profile first sources the previously configured profile from _environment.local or _environment, if any. Duplicate assignments are preserved, with the last one taking effect.

remove_timeknit_project() reverses all of this, leaving other content of those files untouched and deleting files that end up empty.

See also

sitrep() to check the result.