错误:尝试使用 read.csv() 读取 csv 文件时"unexpected input in.."



我正在尝试将CSV文件读取到R中,但我总是收到相同的错误消息

 Error: unexpected input in "read.csv(C:"...

这是我的代码:

read.csv(C:UsershpDocumentsdataset_self_reports_of height., header = TRUE, sep = ",") 

这是因为file参数被认为是字符串。

您实际上有

C:UsershpDocumentsdataset_self_reports_of height

当假定为

"C:/Users/hp/Documents/dataset_self_reports_of height"

也需要在R 中使用这种方式/

因此,您很可能应该以这种方式使用它:

read.csv("C:/Users/hp/Documents/dataset_self_reports_of height", header = TRUE, sep = ",")

我建议您阅读一些R教程以了解R的工作方式。

最新更新