首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从r中打开的.txt文件中选择链接(行)?

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

Stack Overflow用户
提问于 2019-09-29 04:39:52
回答 1查看 48关注 0票数 1

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

在.txt文件中,行(链接)以"Enter“分隔。

下面是下载该文件的链接:

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

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

代码语言:javascript
运行
复制
download_links <- read.table("C:/Users/Desktop/download_Links.txt", sep = "", header = FALSE)
class(download_links)
>
[1] "data.frame"

我想选择文件中的第一个链接(行),但是R提供了所有的文件内容:

代码语言:javascript
运行
复制
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

问题:

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

我将非常感谢你的评论/答复。

EN

回答 1

Stack Overflow用户

发布于 2019-09-29 17:41:13

基于@H1的有益评论,我将回答以下问题,以完成这个主题:

代码语言:javascript
运行
复制
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"
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58152275

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档