Error while reading csv file in R

后端 未结 11 2120
自闭症患者
自闭症患者 2021-02-07 10:37

I am having some problems in reading a csv file with R.

 x=read.csv(\"LorenzoFerrone.csv\",header=T)

Error in make.names(col.names, unique = TRUE) : 
      inva         


        
相关标签:
11条回答
  • 2021-02-07 10:46

    The cause is an invalid encoding. I have solved replacing all the "è" with e

    0 讨论(0)
  • 2021-02-07 10:46

    I know this is an old post, but just wanted to say to non-English natives, that if you use "," as decimal seperator,

    0 讨论(0)
  • 2021-02-07 10:49

    Typically an encoding issue. You can try to change encoding or else deleting the offending character (just use your favorite editor and replace all instances). In some cases R will spit the char location, for example:

    invalid multibyte string 1847

    Which should make your life easier. Also note that you may be required to repeat this process several times (deleting all offending characters or trying several encodings).

    0 讨论(0)
  • 2021-02-07 10:49

    Not sure if this helps, just had a similar issue which I solved by removing " from the csv I was trying to import. The first row of the database had the column names written as "colname","colname2","etc" and I removed all the " and the csv was read in R just fine then.

    0 讨论(0)
  • 2021-02-07 10:53

    You need to specify the correct delimiter in the sep argument.

    0 讨论(0)
  • 2021-02-07 10:57

    I found this problem is caused by code of file, and I solved that by opening it with Windows note, saving with UTF-8, and reopening with Excel(it became garbled at first), and resaving with UTF-8, then it worked!

    0 讨论(0)
提交回复
热议问题