Read.csv() throws error

后端 未结 7 690
暗喜
暗喜 2021-01-18 03:49

I have been trying to read the excel file but seems like there is something wrong. The file is stored in Documents folder in excel format.

These are the error mess

7条回答
  •  离开以前
    2021-01-18 04:21

    By definition a .csv file has comma separated values; in your R code you use tab ("\t") as the delimiter. If you have an actual csv file, you should be able to enter:

    csvfile<-read.csv("csvfilename.csv")
    

    or alternatively

    csvfile<-read.table("csvfilename.csv",sep=",")
    

    though really the first command should suffice. It's strange that you have to specificy a tab to delimit columns in a csv file, unless excel did something wonky to your data table.

    You could always use the xlsx package in R and then write the file to the format you want as well.

提交回复
热议问题