0

My question is exactly similar to this question. I tried all the solutions listed there but they didn't work :(

Only difference is that I am not sourcing other R files. I am going to read csv files that are at the same location as the current R script.

I need this feature as that way I can transfer R file easily to other PCs/systems

I want that solution to work on Rstudio and command line and on Windows and Linux.

I would like to offer a bounty of 50 credits

Community
  • 1
  • 1
user2543622
  • 5,760
  • 25
  • 91
  • 159

1 Answers1

0

How about adding this to your script?

    currentpath <- getwd()

Then you can read the csv file foo.csv with

    read.csv(paste0(currentpath,'/','foo.csv'))

To make the code more platform independent you can explore the normalizePath function.

misspelled
  • 306
  • 1
  • 5