Skip to contents

This function sets up a directory structure that is designed to work well with blaseRtemplates functions. It will create directories where indicated, write a standard .Rprofile document, and modify the user .Renviron file to configure R properly. The function will not overwrite existing directories and will fail when an existing installation is already present in the same location. The only modification outside of the existing directory is to the .Renviron file. If you have existing configurations in your .Renviron file, they will only be changed if they are conflicting. If this is problematic, then you should archive your .Renviron file before running. The new .Renviron file will cause R to use the new .Rprofile in the cache directory and skip existing user- and project-level .Rprofiles.

For the individual user: Identify the location for your blaseRtemplates cache and your R projects. For convenience, these can be within the same parent directory. The cache will hold versioned and hashed binary package files in the library directory. These are the actual instructions used by R when you call up functions. The version/hash structure is tracked by your projects and allows reproducibility. The user_project directory holds symlinks to the specific version/hash packages being used. A new directory is created for each new project. The source directory is used by the package installer, pak, to archive the source files for each package. You should rarely need to look in there. The logs directory holds .Rhistory files. One is created for each R session you open. The .tsv files catalog the entire collection of packages in your cache with their dependencies. The .Rprofile is what sets up your R session to use the proper user_package directory, ensures you are working in a valid project, generates startup messages and sets some helpful options.

This function will create 1 project, called baseproject, in the projects directory which will ensure you are always operating in a project environment. Working outside of a project can have dangerous/unintended consequences.

For the system administrator: the directory structure will work equally well for a multiuser system (e.g. rstudio server) with minor modifications. The .Rprofile generated by the function can be used as Rprofile.site and will apply to all users of that R installation. Each user should have their own project directories with a baseproject on the system. The .Renviron file should be modified for each user to point to this directory and saved in the home directory. There should be a subdirectory in user_projects with each user's ID for their project libraries. Ownership should be given to the user/group and permissions set accordingly, e.g. 755.

Upgrading R versions: since package binaries don't work across minor version changes in R, e.g. 4.2 -> 4.3, you will have to create a new cache directory each time this changes.

Usage

establish_new_bt(cache_path, project_path)

Arguments

cache_path

Path to the blaseRtemplates cache root. Should include the R major and minor version numbers in the final directory. This and all intermediate directories will be created.

project_path

Path to the R projects directory. For convenience, can put this in the same parent directory as cache_path, but not strictly necessary.

Examples

if (FALSE) { # \dontrun{
if(interactive()){
  establish_new_bt(cache_path = "<some_directory>/r_4_2_cache", project_path = "<some_directory>/projects")
 }
} # }