我想从网页上的文本文件中保存数据并将其加载到 R 中。我遇到了一些麻烦,因为当我右键单击无法导入的数据时,我只能“将链接另存为 html”。理想情况下,我应该能够“另存为”一个正确的文本文件并使用 read.table() 加载到 R 中。
否则,当我尝试复制并粘贴到 Excel 中时,它无法识别这些列。
我很确定在过去右键单击数据会显示“另存为”,列出文件格式的各种选项。但是,这一次我无法使用 .html 以外的格式保存数据。
提前致谢。
运行代码后的数据头:
data=read.delim('https://wattlecourses.anu.edu.au/pluginfile.php/2439477/mod_resource/content/1/yieldfert.txt', header = F,stringsAsFactors = F)
head(data)
运行代码后的输出和错误:
> data1=read.table("https://wattlecourses.anu.edu.au/pluginfile.php/2439477/mod_resource/content/1/yieldfert.txt", quote = "")
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
line 1 did not have 5 elements