我一直在尝试从我即将发表的一篇文章中导入我的数据。我创建了工作目录的路径以及文章的链接。当我从 sublime 复制链接并发布到 R 时,它仍然读取错误。我该怎么做才能使链接正常工作并能够在 R 中导入我的数据?
请查看我的问题:
setwd("C:/Users/17184/OneDrive/Desktop/JerryRR") malaria_prev_df <- read.table (file = "C:/Users/17184/OneDrive/Desktop/JerryRR/malaria_prev_tab.txt", + header = TRUE, + sep = "\t", + stringsAsFactors = FALSE) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'C:/Users/17184/OneDrive/Desktop/JerryRR/malaria_prev_tab.txt': No such file or directory head(malaria_prev_df) Error in head(malaria_prev_df) : object 'malaria_prev_df' not found
我尝试创建从我的工作目录到文章的可能链接,以将数据导入 R,但它不起作用。看起来仍然有一个错误或多个错误。
图书馆(openxlsx)
setwd("C:/Users/17184/OneDrive/Desktop/JerryRR")
Malaria_Prev.xlsx_df <- read.xlsx(xlsxFile = "C:/Users/17184/OneDrive/Desktop/JerryRR/Malaria_Prev.xlsx",
sheet = 1,
startRow = 1,
colNames = TRUE)
head(Malaria_Prev.xlsx_df)