Configures a project so that knitr and Quarto renders started from it use
timeknit, without touching ~/.Rprofile or the site-wide profiles.
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 callsuse_timeknit(). This covers R sessions started in the project,rmarkdown::render()andknitr::knit()from those sessions, and Quarto renders of documents in the project root. When the file is created from scratch the block also sources~/.Rprofilefirst, because a project.Rprofileotherwise replaces it.In a Quarto project (one with
_quarto.yml), also writes a.timeknit.Rprofileand pointsR_PROFILE_USERat it from_environment.local. Quarto starts R in each document's own directory, where the project.Rprofileis 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.localholds 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.
