我有一个.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问题:
如何每次只能从文件中选择一个链接(行)?
我将非常感谢你的评论/答复。
发布于 2019-09-29 17:41:13
基于@H1的有益评论,我将回答以下问题,以完成这个主题:
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"https://stackoverflow.com/questions/58152275
复制相似问题