我无法下载文件,我如何更新下面的函数,如果我打印一些值FILE_NAMES,它们是空的.会出什么问题呢?
# Set the download URL
url <- "https://ftp.ncbi.nlm.nih.gov/pub/pmc/manuscript/xml/"
# Create a vector of file numbers to download
file_nums <- sprintf("%02d", 1:3)
# Create a pattern to match the beginning of the file names
pattern <- paste0("^author_manuscript_xml.PMC0", file_nums)
# Get a vector of all file names from the URL and filter based on the pattern
file_names <- grep(pattern, list.files(url), value = TRUE)
# Loop through the file names and download each file
for (file_name in file_names) {
file_url <- paste0(url, file_name)
download.file(file_url, file_name)
}