我想将R数据帧写入Google Cloud Storage存储桶.我在R中使用googleCloudStorageR库,这是我的代码-
I want to write R dataframe to Google Cloud Storage bucket. I am using googleCloudStorageR library in R and here is my code -
################### START ############################### options(googleAuthR.scopes.selected = "www.googleapis/auth/cloud-platform") # load the libraries library("googleAuthR", lib.loc="/home/user/packages" ) library("googleCloudStorageR", lib.loc="/home/user/packages") gar_gce_auth() name <- c("john","doe") id <- c(1,2) results = as.data.frame(cbind(name,id)) print("writing results to GCS") # Set bucket name bucket <- "my-bucket" gcs_global_bucket(bucket) print("bucket set.") # Upload that file to the global bucket gcs_upload(file = results , name = "results.csv") ################## END ################################这会将数据帧加载到存储区my-bucket中.
This loads the dataframe to bucket my-bucket.
现在,我想保存相同的数据帧,但是保存到不同的文件夹结构中,例如-my-bucket\my-folder\results.csv.如何将数据框保存到GCS中的此新路径?
Now I want to save this same dataframe but to a different folder structure, for example - my-bucket\my-folder\results.csv . How can I save the dataframe to this new path in GCS ?
cran.r-project/web /packages/googleCloudStorageR/googleCloudStorageR.pdf
推荐答案您将名称更改为文件夹结构(unix样式),因此更改了最后一行:
You change the name to be your folder structure (unix style), so change the last line:
# Upload that file to the global bucket gcs_upload(file = results , name = "my-folder/results.csv")更多推荐
如何将R数据帧写入Google Cloud Storage存储桶文件夹
发布评论