I am trying to get an application running on shinyapps.io.
First step is to load a rds file for dropbox access.
The the app is supposed to dowload one folder of the dropbox on the server.
I want to create a directory in the "static" directory of the app.
I tried
dir.create (static/...)
dir.create (./static/...)
both works fine locally, but it seems dir.create () does not work on the shinyapps server.
https://colomb.shinyapps.io/resultsgallery_software/
https://github.com/smartfigures-dar/SmartFig_Rbased_prototype/tree/dropbox_integration
Note that it seems to work on the 2 first instance and then no more:
local:
for (j in folders$path_display){
print(j)
foldercreated <-dir.create(paste0("./static",j))
}
[1] "/SFB-resultgallery"
[1] "/SFB-resultgallery/Figures"
[1] "/sfb-resultgallery/Figures/atg6-9_KD_in_brain"
[1] "/sfb-resultgallery/Figures/keep_it_short,_no_more_than1"
[1] "/sfb-resultgallery/Figures/2e"
[1] "/sfb-resultgallery/Figures/keep_it_short,_no_more_than"e
shinyapps.io log message:
2019-07-05T09:42:45.679221+00:00 shinyapps[1012452]: [1] "/SFB-resultgallery"
2019-07-05T09:42:45.679636+00:00 shinyapps[1012452]: [1] "/SFB-resultgallery/Figures"
2019-07-05T09:42:45.679740+00:00 shinyapps[1012452]: [1] "/sfb-resultgallery/Figures/atg6-9_KD_in_brain"
2019-07-05T09:42:45.679936+00:00 shinyapps[1012452]: Warnung in dir.create(paste0("./static", j))
2019-07-05T09:42:45.679938+00:00 shinyapps[1012452]: kann Verzeichnis './static/sfb-resultgallery/Figures/atg6-9_KD_in_brain' nicht erzeugen. Grund 'No such file or directory'
Short answer: never capitalise folder names.
It took forever to get to the problem and solve it, although the problem is tiny: shinyapps.io and windows deal differently with capital letters: things were saved in "Figures/" and the app tries to access "figures/", no to mention that dropbox messes with it too (file in Figures/ are seen in figures/...)
I wonder if this is somewhere in the doc...
(I am still struggling with the problem hours after finding it ...)
Related
I know I'm not the only one with this problem but I have tried several solutions and nothing has worked yet. When I'm deploying my shinyapp (that works perfectly on Windows 11 and 10) i get this warning:
Warning messages:
1: In fileDependencies.R(file) :
Failed to parse C:/Users/nicol/AppData/Local/Temp/RtmpQF8uhX/file438c489067a3/app.R ; dependencies in this file will not be discovered.
I have tried saving my app as a UTF-8 file (there are German Umlauts in it) in RStudio and I have tried to use this as the first line of my code:
options(encoding = "UTF-8")
I deploy on the Rstuido GUI. Maybe that's the problem. But I don't understand how to deploy through the commandline.
Thx for your help
Found a solution. You have to deploy your app through the commandline and use this:
tmp.enc <- options()$encoding
options(encoding = "UTF-8")
rsconnect:: deployApp()
This can be a bit complicated because you can't chose from the GUI what you want to upload to shinymaps.io but at least it works.
I am trying to use readxl::read_excel to import tabular data from an excel spreadsheet (.xlsx and .xls) into R. I have had success with this function when reading spreadsheets from Desktop, but I am having trouble reading from my Documents folder now.
I tried reading both .xlsx and .xls formats of the same file and got 2 different error messages.
# Check the working directory
[1] "\\\\isdowfsv04/D100Home/e525902"
# Read .xlsx
specs <- read_excel("Class Specs Sept 2016.xlsx")
Error: 'exdir' does not exist
# Read .xls
specs <- read_excel("Class Specs Sept 2016.xls")
Error: path[1]="\\isdowfsv04/D100Home/e525902/Class Specs Sept 2016.xls": Access is denied
The second message made me think I don't have permission to read/write data here, but I create folders/files here all the time. I have even used another R library, readr package, to import .csv files from this same directory.
# Using readr to import .csv version of the file works fine.
specs <- read_csv("\\\\isdowfsv04/D100Home/e525902/Class Specs Sept 2016.csv")
Based on other posts I've seen, it seems like a permission issue, but it's unclear to me how to fix it.
I tried using Sys.setenv() to change the temporary folders location to somewhere I know I have permission to write (i.e., Desktop) because I thought readxl used these paths when reading the data. But that didn't work because I got the exact same error messages.
Sys.getenv(c("TEMP", "TMP"))
TEMP TMP
"C:\\Users\\e525902\\AppData\\Local\\Temp" "C:\\Users\\e525902\\AppData\\Local\\Temp"
# Change temp file paths to the Desktop
Sys.setenv(TEMP = "C:\\Users\\e525902\\Desktop")
Sys.setenv(TMP = "C:\\Users\\e525902\\Desktop")
I am using a PC at work and the Documents folder is actually a network drive. I have used read_excel to import .xlsx files from other network folders, but this one is giving me trouble. Below is more information on the system I'm using.
Sys.info()
sysname release version
"Windows" "7 x64" "build 7601, Service Pack 1"
nodename machine login
"10004053WDT" "x86-64" "e525902"
user effective_user
"e525902" "e525902"
search()
[1] ".GlobalEnv" "package:readr" "package:readxl" "tools:rstudio" "package:stats"
[6] "package:graphics" "package:grDevices" "package:utils" "package:datasets" "package:methods"
[11] "Autoloads" "package:base"
# R version
version$version.string
version.string R version 3.2.5 (2016-04-14)
I ran into the same issue. It was occurring to me when I set my working directory to the base location of the excel files, and then in the read excel, using a relative path to get to the directory.
Once I rebooted R, and instead kept my working directory as the default, and then used the full file path in the read_excel function, my exdir error went away.
Let me know if this works for you. I was also on a network drive at work with a windows 7 64-bit system.
The current working directory is displayed by the RStudio IDE within the title region of the Console pane. You can also check your current working directory by running the command getwd() in the console.
First, apologies for a lack of a reproducible example, but I cannot really provide one as I believe the problem lies within my network settings. Please treat this question as a call for help in debugging the issue...
After opening in RStudio a project stored on a network drive and running the very first instruction (being it a package load or even a <- 1) I am seeing a really weird output in the console:
> a <- 1
Warning message:
In dir.create(tempPath, recursive = TRUE) :
cannot create dir 'F:\Marketing', reason 'Permission denied'
I have all possible temp dirs set up in user environment variables (TEMP, TMP, TMPDIR) and Sys.getenv() is printing them correctly.
"F:\Marketing" is a valid path on my network drive and it is a root directory of the project.
I have tried to debugonce(dir.create) in .RProfile to see what the tempPath is, but unfortunately this resulted in an "invalid 'envir' argument" error.
After copying the project to a local drive the problem disappears, so this is clearly a network drive/network setup problem, but I do not know where to dig more and my IT dept. is not really useful here...
Any ideas how to debug this warning?
I am trying to use readxl::read_excel to import tabular data from an excel spreadsheet (.xlsx and .xls) into R. I have had success with this function when reading spreadsheets from Desktop, but I am having trouble reading from my Documents folder now.
I tried reading both .xlsx and .xls formats of the same file and got 2 different error messages.
# Check the working directory
[1] "\\\\isdowfsv04/D100Home/e525902"
# Read .xlsx
specs <- read_excel("Class Specs Sept 2016.xlsx")
Error: 'exdir' does not exist
# Read .xls
specs <- read_excel("Class Specs Sept 2016.xls")
Error: path[1]="\\isdowfsv04/D100Home/e525902/Class Specs Sept 2016.xls": Access is denied
The second message made me think I don't have permission to read/write data here, but I create folders/files here all the time. I have even used another R library, readr package, to import .csv files from this same directory.
# Using readr to import .csv version of the file works fine.
specs <- read_csv("\\\\isdowfsv04/D100Home/e525902/Class Specs Sept 2016.csv")
Based on other posts I've seen, it seems like a permission issue, but it's unclear to me how to fix it.
I tried using Sys.setenv() to change the temporary folders location to somewhere I know I have permission to write (i.e., Desktop) because I thought readxl used these paths when reading the data. But that didn't work because I got the exact same error messages.
Sys.getenv(c("TEMP", "TMP"))
TEMP TMP
"C:\\Users\\e525902\\AppData\\Local\\Temp" "C:\\Users\\e525902\\AppData\\Local\\Temp"
# Change temp file paths to the Desktop
Sys.setenv(TEMP = "C:\\Users\\e525902\\Desktop")
Sys.setenv(TMP = "C:\\Users\\e525902\\Desktop")
I am using a PC at work and the Documents folder is actually a network drive. I have used read_excel to import .xlsx files from other network folders, but this one is giving me trouble. Below is more information on the system I'm using.
Sys.info()
sysname release version
"Windows" "7 x64" "build 7601, Service Pack 1"
nodename machine login
"10004053WDT" "x86-64" "e525902"
user effective_user
"e525902" "e525902"
search()
[1] ".GlobalEnv" "package:readr" "package:readxl" "tools:rstudio" "package:stats"
[6] "package:graphics" "package:grDevices" "package:utils" "package:datasets" "package:methods"
[11] "Autoloads" "package:base"
# R version
version$version.string
version.string R version 3.2.5 (2016-04-14)
I ran into the same issue. It was occurring to me when I set my working directory to the base location of the excel files, and then in the read excel, using a relative path to get to the directory.
Once I rebooted R, and instead kept my working directory as the default, and then used the full file path in the read_excel function, my exdir error went away.
Let me know if this works for you. I was also on a network drive at work with a windows 7 64-bit system.
The current working directory is displayed by the RStudio IDE within the title region of the Console pane. You can also check your current working directory by running the command getwd() in the console.
I am having some trouble knitting a markdown file which is sitting on a network drive. I am using rmarkdown::render() to knit the file. I have tracked the problem down 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 get this warning because I certainly do have both read and write access to the file.
But calling file_path_as_absolute(), which is just a wrapper for normalizePath(), turns that 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 am pretty sure that the problem relates to the fact that the file is on a network drive because I do not encounter this issue when I do the same thing with a file on my local drive. However, as mentioned above, I do have read/write access to this file.
Does anybody have any ideas for the source of this problem? And, more importantly, a possible solution?
Based on a 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
Thanks!
Best regards,
Andrew.
Same problem here.
I ended moving the project in a local folder and copying the produced file with the command file.copy.
It is a generic solution and if someone find one better, I am interested in.
Realise this is an old question, but I just had the same issue. For me, mapping the network drive via windows explorer worked.
It is important to close the current R Session and re-open the Rproj file from the mapped drive location.
It all worked normally from there.