r - 如何使用 download.file() 遍历列中的 url
问题描述
我有这个df
我需要下载所有文件的网址:
library(RCurl)
view(df)
Date column_1
<chr> <chr>
1 5/1/21 https://this.is.url_one.tar.gz
2 5/2/12 https://this.is.url_two.tar.gz
3 7/3/19 https://this.is.url_three.tar.gz
4 8/3/13 https://this.is.url_four.tar.gz
5 10/1/17 https://this.is.url_five.tar.gz
6 12/12/10 https://this.is.url_six.tar.gz
7 9/9/16 https://this.is.url_seven.tar.gz
8 4/27/20 https://this.is.url_eight.tar.gz
9 7/20/15 https://this.is.url_nine.tar.gz
10 8/30/19 https://this.is.url_ten.tar.gz
# … with 30 more rows
当然,我不想download.file(url='https://this.is.url_number.tar.gz', destfile='files.tar.gz', method='curl')
为每个 url 输入 40 次。如何循环使用 column_1 中的所有 url download.file()
?
解决方案
for
这是循环中的一种方式
for(i in seq_len(nrow(df))) {
download.file(url = df$column_1[i],
destfile = paste0('files', df$column_ID_number[i],
'.tar.gz'), method = 'curl')
}
推荐阅读
- c++ - 如何使用 c++ 和 boost 库生成 json
- ios - Twitter Kit 不能在 Swift 应用程序中重定向
- class - Kotlin 函数到类
- python - 如何使用python从pdf中提取数字签名?
- npm - 纱线会忽略 .npmignore 吗?
- android - 如何在 HorizontalGridView 中始终将焦点放在第 0 位?
- android - 标记某些视图以使其行为相似
- javascript - 如何从按钮获取 data-vale1、data-value2、data-value3
- javascript - 将外部 json 文件转换为 html 表
- aws-appsync - 如何在 aws appsync 解析器中使用“$util.list.copyAndRetainAll(List, List)”?