如何从 r 中打开的.txt文件中选择链接(行)?



我有一个.txt文件包含 3 个下载链接。

行(链接(在.txt文件中用"Enter"分隔。

以下是下载文件的链接:

https://www.dropbox.com/s/m3hz5haz0ixre14/download_Links.txt?dl=1

我使用以下代码在 R 中打开了.txt文件:

download_links <- read.table("C:/Users/Desktop/download_Links.txt", sep = "", header = FALSE)
class(download_links)
>
[1] "data.frame"

我想选择文件内的第一个链接(行(,但 R 给了我所有文件内容:

download_links[1]
>                                                                                                                                                                                                                         
V1
1 http://esgf-data2.diasjp.net/thredds/fileServer/esg_dataroot/CMIP6/HighResMIP/MRI/MRI-AGCM3-2-H/highresSST-present/r1i1p1f1/day/pr/gn/v20190711/pr_day_MRI-AGCM3-2-H_highresSST-present_r1i1p1f1_gn_19500101-19591231.nc
2 http://esgf-data2.diasjp.net/thredds/fileServer/esg_dataroot/CMIP6/HighResMIP/MRI/MRI-AGCM3-2-H/highresSST-present/r1i1p1f1/day/pr/gn/v20190711/pr_day_MRI-AGCM3-2-H_highresSST-present_r1i1p1f1_gn_19600101-19691231.nc
3 http://esgf-data2.diasjp.net/thredds/fileServer/esg_dataroot/CMIP6/HighResMIP/MRI/MRI-AGCM3-2-H/highresSST-present/r1i1p1f1/day/pr/gn/v20190711/pr_day_MRI-AGCM3-2-H_highresSST-present_r1i1p1f1_gn_19700101-19791231.nc

问题:

如何每次只能从文件中选择一个链接(行(?

我将非常感谢您的评论/回答。

根据 @H 1 的有用评论,我正在回答这个问题以完成本主题:

download_links <- readLines("C:/Users/Desktop/download_Links.txt")
class(download_links)
>
[1] "character"
download_links[1]
[1] "http://esgf-data2.diasjp.net/thredds/fileServer/esg_dataroot/CMIP6/HighResMIP/MRI/MRI-AGCM3-2-H/highresSST-present/r1i1p1f1/day/pr/gn/v20190711/pr_day_MRI-AGCM3-2-H_highresSST-present_r1i1p1f1_gn_19500101-19591231.nc"

最新更新