简体   繁体   中英

How to solve Error while reading a CSV file in R

hey guys im a beginner in R and want to read a csv file, but I get errors.

I tried this:

read.csv("unit_values_feudal.csv",colClasses = c("character","numeric","numeric","numeric","numeric","numeric"))

got this error:

error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  :    scan() expected 'a real', got '"'

added a screen of the file:

csv.file

You can simply remove the second argument colClasses and R will read the CSV.

Here is something you can try:

read.csv("unit_values_feudal.csv") .

Furthermore, as some have pointed out, you probably might want to remove the commas before and after your numbers , and the code you have written will work just fine.

It might be better to check the csv file in Notepad rather than excel, I get a feeling that you are not importing the csv into excel using the right delimiter.

Other than that, I think read.csv("unit_values_feudal.csv") will just work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM