Working with Dropbox and R Studio

If you are using dropbox for keeping your R script files and you are working from multiple computers, setting the working directory every time could be a real pain. The good news is that you can avoid the hassle using rtstudioapi and single line of code in the beginning of your R file.

First install rstudioapi library using packages part of your R Studio environment.

Add the following line of code in the beginning of each of your R script files.

setwd(dirname(rstudioapi::getActiveDocumentContext()$path)) 

Voila! There is no more need to update the path using setwd every time you are using a different computer.

 

Leave a Reply

Your email address will not be published. Required fields are marked *