Search code examples
rcloud

How can I specify the file owner and permissions when using write.csv in R?


I am using an rShiny app in RCloud. When I use write.csv the file is saved as nobody nobody and then I am unable to read it back in using read.csv. Is the solution to specify user and file permissions as options in the write.csv function or is there a different way?

I plan to run construct multiple results, append each to a file and then let the user email that file to themselves.

    write.csv(lob_comp,'Rcopy.csv')
    lob_comp<-read.csv('Rcopy.csv')

-rw-r----- 1 nobody nobody 399 Aug 25 00:51 Rcopy.csv

$ cat Rcopy.csv

cat: Rcopy.csv: Permission denied


Solution

  • an rShiny app user that doesn't have an account is actually logged in as 'nobody' if that is how you have configured RCloud. Since 'nobody' wrote the file then 'nobody' can chmod it. Put this line in your Shiny code.

    system("chmod 644 Rcopy.csv")

    Once you've chmod'd the file you should be able to read it.