問題

我有一個.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"
 

  相同標籤的其他問題

rdataframe