Error : "unexpected input in.." when trying to read csv file with read.csv()

Viewed 5958

I am trying to read a csv file into R but I am always getting the same error message

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

Here is my code :

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

It is because the file argument is suppose to be a character string.

You actually have

C:\Users\hp\Documents\dataset_self_reports_of height

When it's suppose to be

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

Also in R \ need to be use this way /.

So you should most likely use it this way :

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

I suggest you read a few R tutorials to know how R works.

Related