Creating a personal library for R packages - Macintosh.

This is an expanded version of these instructions
  1. Navigate to your home directory. In the Finder, use Go -> HOME
  2. Create a new directory (folder) for the R pacakges. Traditionally this is called Rlibs

  3. You now want to create a special (hidden) file called .Renviron (yes it beings with a period) that contains a single line
        R_LIBS=~/Rlibs
    This will tell R that your personal (package) library is the directory called Rlibs in your home directory.

    To create the .Renviron file will require a litte work with the Terminal application.

  4. Launch the Terminal application: Go -> Applications -> Utilities -> Terminal


    This gives a window looking similar to:

  5. Type the unix command
       ls
    to list the files in your home directory. You should see the Rlibs directory that you created earlier.

  6. Type the unix command (or copy and paste the line below)
        echo "R_LIBS=~/Rlibs" > .Renviron
    Don't forget the period (.) before the Renviron name and besure that your case matches.
  7. Type the unix command
        ls -a
    to see all of the files in your directory, including those with an initial period. You should now see a .Renviron file in the listing. Don't worry about the other files.
  8. Finally, type the unix command to verify that the .Renviron file has been set properly:
        more .Renviron

Now launch R (or Rstudio), and type the following command in the console. You should see the new paths for your personal (package) library:


[ SFU Statistics and Actuarial Science Home | SFU Home]
Email comments or suggestions to Carl Schwarz (cschwarz@stat.sfu.ca)
© 2016 Carl James Schwarz Last updated 2016-07-05.