Finding an absolute path for a file on a network drive
I am having problems attaching a markdown file that is on a network drive. I am using rmarkdown :: render () to attach a file. I traced the problem back to the file_path_as_absolute () function.
I have a markdown file, foo.Rmd, in my working directory.
> list.files()
[1] "$RECYCLE.BIN" "2014-11-04-popular-wagers-distribution.pdf"
[3] "db-connection.R" "desktop.ini"
[5] "figure" "foo.md"
[7] "foo.Rmd" "game-popularity.R"
[9] "My Data Sources" "player-data-game-monitoring.tsv"
[11] "player-linking.R" "player-pca.R"
[13] "query-1.sql" "query-2.sql"
[15] "R" "report-test-2.Rmd"
[17] "report-test.md" "report-test.Rmd"
[19] "report-test.xxx" "SQL Server Management Studio"
[21] "test.md" "test.R"
[23] "test.Rmd" "Thumbs.db"
I can find the absolute path:
> normalizePath("foo.Rmd")
[1] "\\\\dernetapp02\\h$\\users\\AndrewCo\\myCitrixFiles\\Documents\\foo.Rmd"
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="foo.Rmd": Access is denied
This works, although it generates a warning. I am not sure why I am getting this warning, because I certainly have both read and write access to the file.
But calling file_path_as_absolute (), which is just a wrapper around normalizePath (), turns this warning into an error.
> tools::file_path_as_absolute(input)
Error in normalizePath(path.expand(path), winslash, mustWork) :
path[1]="foo.Rmd": Access is denied
I'm pretty sure the problem is because the file is on a network drive, because I don't run into this problem when I do the same with a file on my local drive. However, as mentioned above, I have read / write access to this file.
Does anyone have any ideas for the source of this problem? And more importantly, a possible solution?
Based on the suggestion (below), I tried mapping to a network drive:
> system("net use s: \\\\dernetapp02\\h$")
This seemed promising, but ended up with the same results:
> normalizePath("s:\\users\\AndrewCo\\myCitrixFiles\\Documents\\foo.Rmd")
[1] "s:\\users\\AndrewCo\\myCitrixFiles\\Documents\\foo.Rmd"
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="s:\users\AndrewCo\myCitrixFiles\Documents\foo.Rmd": Access is denied
Thank!
Regards, Andrew.
source to share