Locating R and R Adjacent Software and Configuration Files

My personal R administration on Windows 10

Shannon Pileggi true
Two home directories are colored bright purple, the software is colored lime green, and the configuration files are colored a mustard yellow. C/ |--rtools42/ |--Program Files/
      |--OneDrive - Memorial Sloan Kettering Cancer Center/

Figure 1: File tree visualizing the hierarchy of R and R adjacent software and configuration files on my Windows 10 operating system.


There is a lot to keep track of to install and maintain R and R adjacent software and configuration files. Here is what my Windows 10 set up looks like, with associated code if available. Your set up might differ from mine, but you can use the associated code to figure it out. 🤗

Item Code Location
Home drive Sys.getenv("HOMEDRIVE") C:/
User home directory Sys.getenv("USERPROFILE"), Sys.getenv("HOMEPATH"), fs::path_home() C:/Users/pileggis
R home directory Sys.getenv("HOME"), Sys.getenv("R_User"), fs::path_home_r() C:/Users/pileggis/OneDrive - Memorial Sloan Kettering Cancer Center/Documents
R R.home(), Sys.getenv("R_HOME") C:/Program Files/R/R-4.2.0
R packages .libPaths() C:/Program Files/R/R-4.2.0/library
RStudio C:/Program Files/RStudio
Rtools devtools::find_rtools(), devtools::has_devel() C:/rtools42
Git C:/Program Files/Git
Quarto C:/Program Files/Quarto
.Renviron usethis::edit_r_environ() C:/Users/pileggis/OneDrive - Memorial Sloan Kettering Cancer Center/Documents/.Renviron
.Rprofile usethis::edit_r_profile() C:/Users/pileggis/OneDrive - Memorial Sloan Kettering Cancer Center/Documents/.Rprofile
.gitconfig usethis::edit_git_config() C:/Users/pileggis/.gitconfig
.shrtcts.R shrtcts::locate_shortcuts_source() C:/Users/pileggis/OneDrive - Memorial Sloan Kettering Cancer Center/Documents/.shrtcts.R


When Travis Gerke tweeted about the breaker of chains keyboard shortcut, I was eager to try it out!

However, it was not immediately clear to me where to save the the shrtcts.R configuration file. This took a bit of trial and error to figure out, and led me to document where everything R and R adjacent is located.


In this post I refer to two packages and two books.


  1. usethis for helpers that automate repetitive tasks during project set up and development.

  2. fs for cross-platform file system operations.


  1. Happy Git with R, a manual for integrating Git with R; abbreviated to Happy Git for the remainder of this post.

  2. What they Forgot to Teach You About R, is in progress but still extremely helpful documentation on best practices when working in R; abbreviated to WTF for the remainder of this post.


I am working on a computer supplied by employer with a Windows 10 operating system.

When getting started with a Windows computer, I recommend changing default settings such that:

  1. Display the full path in the title bar

  2. Show hidden files, folders, and drives

  3. Hide extension for known file types

Administrator rights

Much of how you work in Windows depends on your level of rights. Fortunately, I was granted administrator privileges on my work laptop, which allows me to install software and save configuration files where I want to.

If you do not have administrator privileges, knowing this can still help you work with IT to complete your set up or find alternate viable locations.


On Mac OS, the “user home directory” and the “R home directory” are the same, but on Windows OS they differ. On Windows, the R home directory tends to be associated with the user’s documents directory, whereas the user home directory is a system level directory.

Home drive

You can locate your home drive through environment variables. See the help file for Sys.getenv and environment variables for more information.



R Home

These three commands all point to the “R home directory”.


C:/Users/pileggis/OneDrive - Memorial Sloan Kettering Cancer Center/Documents


Here, we find the “user home directory”.

Wrapping the function in fs::path_real() allows you to see a consistent full path, rather than the short file path or any other path specification returned by the environment variables.





From the R.home() help file:

The R home directory is the top-level directory of the R installation being run. The R home directory is often referred to as R_HOME, and is the value of an environment variable of that name in an R session.


C:/Program Files/R/R-4.2.0

R packages

.libPaths() shows where R is looking for packages in the current session. If more than one .libPaths() is present, R attaches packages from the libraries in the order shown (searches first library first).

For Windows users:

These locations may work well for some users, and others may want to change the default location. I modified my default location to be under my R installation using the .Renviron configuration file (demonstrated below).

"C:/Program Files/R/R-4.2.0/library"

Lastly, if you are using the renv package for reproducible environments, all utilized packages are installed in global package cache which is shared across all projects. My cache is located at C:/Users/pileggis/AppData/Local/renv.


Rtools is a collection of tools required to build source packages on Windows. Basically, if you want to do anything with packages beyond CRAN (install from github, build locally) on Windows, you need R tools.

In order to work, R tools must be installed at


which is where mine is, too. (rtools 42 is required for R 4.2.0.)

You can confirm if your installation worked properly if


returns TRUE. You can further confirm readiness with


which returns Your system is ready to build packages!


As recommended in Happy Git Ch 6.2 Install Git on Windows, git is installed at

C:/Program Files/Git.


Quarto is an open source publishing system backed by RStudio that began to receive public endorsement in April 2022.

The Quarto installation allowed me to choose between a user specific versus an all-user installation, which can be very helpful depending on your administrative privileges. I chose the latter, and for me Quarto is installed at

C:/Program Files/Quarto.



The .Renviron file contains environment variables that are set in R Sessions (this does not contain R code).

To edit this file, submit:


The user-level .Renviron file lives in the base of the user’s home directory. For me, that means

C:/Users/pileggis/OneDrive - Memorial Sloan Kettering Cancer Center/Documents/.Renviron

My .Renviron file has has been modified to establish default library locations for R package installations.

R_LIBS_USER = "C:/Program Files/R/library/%v"

As explained in WTF Ch 8.4 How to transfer your library when updating R, the %v wildcard automatically adjusts the installation folder when you update to a new R version.


As stated in WTF Ch 7.2 .Rprofile

The .Rprofile file contains R code to be run when R starts up. It is run after the .Renviron file is sourced.

Again, you can edit this file with


and mine lives at

C:/Users/pileggis/OneDrive - Memorial Sloan Kettering Cancer Center/Documents/.Rprofile.

My .Rprofile has been modified two ways:

  1. Establish a default location for R projects created via usethis::create_from_github() or usethis::use_course().

  2. To enable RStudio shortcuts with the shrtcts package.

# ------------------------------------------------------------------------------
#  1/ Establish a default location for R projects created via 
# `usethis::create_from_github()` or `usethis::use_course()`
options(usethis.destdir = "C:/Users/pileggis/Documents/gh-personal")

# ------------------------------------------------------------------------------
# 2/ enable create RStudio shortcuts with the shrtcts package
if (interactive() && requireNamespace("shrtcts", quietly = TRUE)) {
  shrtcts::add_rstudio_shortcuts(set_keyboard_shortcuts = TRUE)


You can open your .gitconfig file for editing with


My .gitconfig file lives at:


and has been modified to allow me to switch between work and personal github identities when working on R projects, which is described in more detail in GitHub ssh and config with multiple accounts by Travis Gerke.


The .shrtcts.R file contains R code that defines the enabled shortcuts. Mine is located in my R home directory at

"C:/Users/pileggis/OneDrive - Memorial Sloan Kettering Cancer Center/Documents/.shrtcts.R"

I currently have two shortcuts enabled:

  1. breaker of chains (mentioned in Background), and

  2. automatically end comments with dashes to 80 characters - see this tweet for details.


This topic probably isn’t exciting for many, but having this understanding can save you time during installation and troubleshooting. And maybe next I get set up on a new OS it will go quicker. 😊


Thanks to Travis Gerke for inspiring me to try new things in R! Thanks to Omar Chua, who provided hours of IT support as I was waiting for administrative privileges. And thank you to Jenny Bryan and David Aja for their feedback on this post.


Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

Pileggi (2022, June 2). PIPING HOT DATA: Locating R and R Adjacent Software and Configuration Files. Retrieved from https://www.pipinghotdata.com/posts/2022-06-02-locating-r-and-r-adjacent-software-and-configuration-files/

BibTeX citation

  author = {Pileggi, Shannon},
  title = {PIPING HOT DATA: Locating R and R Adjacent Software and Configuration Files},
  url = {https://www.pipinghotdata.com/posts/2022-06-02-locating-r-and-r-adjacent-software-and-configuration-files/},
  year = {2022}