我正试图直接下载一份R的补充材料,但遇到了问题。首先,我尝试了:
datatable = fread("https://doi.org/10.1371/journal.pone.0242866.s001")
第一个问题是:
Error in fread("https://doi.org/10.1371/journal.pone.0242866.s001") :
embedded nul in string: 'xf7xc5B1xfcLxf8xu~xad 16 01xddL5(xb2I`x8bҶ 05tLxeePdx97"{ 24xd9'p@C 31Rx9b#x8a 34Sx9b 23 02xa7 04Ψxcd9E.(rIx91+ 01xddM~Mi7x94vKxe0x8exd2&tx85&)xc6xd6 21Uxd6a 23x96X177 33Fxde'J|x9fYx99 37L 30ǫxdc 17xefexe1xx91xfdx89xd2?lx84q6T xc1x84qD* 01 37xab 32xf0(x8a Q 25xf8Xx95A0axecxb3'
In addition: Warning message:
In fread("https://doi.org/10.1371/journal.pone.0242866.s001") :
Detected 1 column names but the data has 3 columns (i.e. invalid file). Added 2 extra default column names at the end.
我试过
datatable = data.table(read.csv("https://doi.org/10.1371/journal.pone.0242866.s001"))
然而,结果只给我带来了一个变量。
所以我尝试了
datatable = data.table(read.csv2("https://doi.org/10.1371/journal.pone.0242866.s001"))
同样,问题仍然存在,但的观测次数
当我尝试使用read_excel并添加一个跳过以查看是否可以排除第一行时,路径中出现了错误。
datatable = data.table(read_excel("https://doi.org/10.1371/journal.pone.0242866.s001"), skip = 1)
Error: `path` does not exist: ‘https://doi.org/10.1371/journal.pone.0242866.s001’
有人能帮我吗?
您可以使用openxlsx
和tail()
:
library(openxlsx)
datatable <- openxlsx::read.xlsx(
'https://doi.org/10.1371/journal.pone.0242866.s001', sheet = 1
) %>%
tail(-1)
试试这个:
library(openxlsx)
openxlsx::datatable = read.xlsx("https://doi.org/10.1371/journal.pone.0242866.s001", sheet = 1)
我参考了Abdinardo Oliveira对这个问题的回答。