Working directory using an RStudio project on a USB drive?

If I set up an RStudio project on a USB key, open it and run getwd() on my mac, then it returns `/Volumes/disk_name'. So that's fine.
I'm just curious what it would return on a PC? I've never used R on a PC.
Would a person be able to move back and forth from a Mac and a PC with R and RStudio installed on each, working on the files each time?

Projects should be portable between different platforms as long as relative references are used for directories from the project root. I have no problem copying projects between Windows PCs and a Linux server. I presume the same would apply for Macs, too.

Just remember to use "/" for directories, rather than double backslashes "\" which are only valid in R for Windows (I believe).

Thanks, can you give a quick explanation of what relative references mean? I think I know what you mean, you're talking about relative references to the root path directory. But what would this look like in practice?

If you have a project in "/Volumes/disk_name" as per your example, then an absolute reference to a file would be:

"/Volumes/disk_name/data/myfile.csv"

The equivalent relative reference would be:

"data/myfile.csv"

If you move the project to e.g. a Windows PC, then you could still use the relative reference even if the project was moved to e.g. "C:\Documents\NewProject".

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.