我正在尝试创建一个循环,我可以在其中为一堆文件执行相同的功能集。但是,这些文件存储在谷歌驱动器(xlsx 文件)中的共享文件夹中,我似乎无法获得“找到它们”的代码。我在 Mac 上工作(如果有什么不同的话)。
这是我尝试过的一个例子:
library("googledrive")
library("readxl")
library("curl")
library("googlesheets")
library("xlsx") # and a few more which I have tried!
> setwd("/Users/xxx/Documents/R") #working on a Mac
> WS.URL <- "https://drive.google.com/drive/u/0/folders/xxx" # this is the shared
drive folder containing numerous xlsx files
##a - the main one I am trying to do ###
> list.files(path = "WS.URL")
character(0) ## there are about 10 files in this folder which aren't showing up. I can't create a loop if I can't retrieve the files.
#b
> nfiles <-length(WS)
> nfiles
[1] 1 # should be about 10
#c
dest <- ("/Users/xxx/Documents/R")
try(download.file("WS.URL", dest))
我不知道我是否遗漏了一些非常明显的东西,仍然要掌握 R。当然这应该很简单吗?
帮助!