Skip to content

R for Journalists

Unlock the power of R

  • What Is R?
  • R for Rob
  • GitHub
  • Twitter
  • Etsy
  • Home
  • 2017
  • March
  • 24
  • How to Set Your Working Directory in RStudio on a PC

How to Set Your Working Directory in RStudio on a PC

Posted on March 24, 2017 By Rob
Learn

This is a quick tip to avoid having to use the setwd() function to set your working directory all the time.

Assuming you are working on a PC using RStudio, here is how to change your working directory to a R sub-folder. To do this, I made use of this guide.

Step 1: Go to C:\Program Files\R\[your_version]\etc

In here you will find a file called ‘Rprofile.site’.

Step 2: Open this file in a text editor

It should have a number of options pre-loaded.

Step 3: Add a new command at the bottom

It should say something like the following, depending how your files are stored:

setwd("C:/Users/[user]/Documents/R")

Step 4: Restart RStudio

Step 5: run the getwd() function

It should change to your new directory!

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook

Related

Tags: rstats RStudio working directory

Post navigation

❮ Previous Post: Cyclists Involved in Accidents Undertaking
Next Post: Using R to make Freedom of Information requests ❯

Recent Posts

  • I’ve moved my blog over to Substack
  • How to plot a large rural area using Ordnance Survey data in R
  • Check the COVID-19 vaccination progress in your area
  • Let R tell you what to watch on Netflix
  • Sentiment analysis of Nineteen-Eighty-Four: how gloomy is George Orwell’s dystopian novel?

Archives

  • April 2022
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • February 2020
  • December 2019
  • November 2019
  • October 2019
  • April 2018
  • March 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016

Categories

  • Geospatial data
  • Landmark Atlas
  • Learn
  • See
  • Seen Elsewhere
  • Site
  • Uncategorized

Copyright © 2025 R for Journalists.

Theme: Oceanly by ScriptsTown