Reading a file on a network in R Reading a file on a network in R r r

Reading a file on a network in R


You need to escape each backslash, so for the double backslash you need four backslashes, i.e.

read.csv("\\\\shared\\data\\abc.csv",header=T)


in addition, the below also works and should be OS agnostic:

read.csv("//shared/data/abc.csv",header=T)

when running getwd() note how the separator between folders is forward slash (/), as it is on Linux and Mac systems. If you use the Windows operating system, the forward slash will look odd, because you’re familiar with the backslash (\) of Windows folders. When working in Windows, you need to either use the forward slash or escape your backslashes using a double backslash (\\).


Using R's built-in file system functions:

CSVfile <- file.path('\\\\shared', 'data', 'abc.csv')read.csv(CSVfile, header=T)`