2

I have my r data files and scripts in dropbox. That means that when running on different computers the directory structure is not identical.

Hence I want to let my script check where it is located

something like

proj.dir <- whereamI()

I had found a solution in this group as noted by Thomas

proj.dir <- dirname(sys.frame(1)$ofile)

but after an update it stopped to work and just return an error message

Error in sys.frame(1) : not that many frames on the stack

Is there a way to get the same information?

Jørgen K. Kanters
  • 844
  • 1
  • 11
  • 22
  • Are you starting R with a source file from an OS command line? – IRTFM Jan 31 '16 at 09:19
  • No I am running a script. The link above does not help me. I used that but the final solution does not work any more as written above – Jørgen K. Kanters Jan 31 '16 at 10:04
  • I found a workable way. You can define a hidden variable "main.dir" in x:\Program Files\R\R x.x.x\etc\RProfile.site which You set to where Your main R directory is located. Then I have my project below that folder which are individually set in each program as i.e setwd(paste(getwd(),"/int99",sep="")) – Jørgen K. Kanters Dec 25 '16 at 13:01

0 Answers0