Reputation: 13
I have installed R-studio on my Google cloud platform compute instance. By default working directory on R-studio is:
/home/rstudio
Then I mounted a cloud storage bucket on my compute instance. Mounted image path is:
/mnt/gcs-bucket
But when I try to read from files located in this directory on r studio using:
r<-read.csv("/mnt/gcs-bucket/trainS.csv")
I get following error
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file '/mnt/gcs-bucket/trainS.csv': Permission denied
How can I give permissions on files so that they are accessible from R-Studio. I have already tried:
chmod 777 /mnt/gcs-bucket/trainS.csv
But I still get the same error.
Reading file on R works just fine. In R-Studio I an unable change my working directory:
setwd("/mnt/gcs-bucket")
Error in setwd("/mnt/gcs-bucket") : cannot change working directory
Upvotes: 1
Views: 1541
Reputation: 2099
Not sure about how to fix the issue with your approach, but here are 2 different approaches to access files from google cloud storage to your R-studio either in GCE or locally that I find pretty easy:
then access the file from that public link:
read.csv("https://storage.googleapis.com/your-bucket-name/testfile.csv")
If it's a large file, fread() from data.table will be much quicker to load and it gives you an indication of the loading progress(speed, eta):
library(data.table)
fread("https://storage.googleapis.com/your-bucket-name/testfile.csv")
Upvotes: 1