0

Im working a lot on different machines so my files are saved in a dropbox. The path to that dropbox differs between Mac's and Windows based computers.

At the beginning of my R script I want to check where the script is saved in and use that information to read in the excel spreadsheet. Heres a pseudo code for what I mean:

dir <- read_dir(current_script)
excel.file <- file.path("dir/data.xls")

So in the end I dont always have to change the code when I switch the computer.

Is there any function to read out that path?

Zong
  • 6,160
  • 5
  • 32
  • 46
Martin Schmelzer
  • 23,283
  • 6
  • 73
  • 98
  • How are you running your scripts? – MrFlick May 08 '14 at 15:32
  • What do u mean by that? The code provided didnt work for me :/ – Martin Schmelzer May 08 '14 at 19:19
  • Are you opening it in a GUI and highlighting all the text and running it? Are you running `source` on the script file? Are you running the scipt fole from the command line with `Rscript`? Are you using `R CMD`? There are lots of ways to "run scripts." – MrFlick May 08 '14 at 19:20
  • I run my script in RStudio. I actually dont want to source another file which is loacted in the same dorectory. I want to use the path to load an excel sheet....So yeah I highlight all the text and then run it... – Martin Schmelzer May 08 '14 at 19:50

0 Answers0