Issue when importing dataset: `Error in scan(…): line 1 did not have 145 elements`

后端 未结 11 1246
我在风中等你
我在风中等你 2020-11-28 22:14

I\'m trying to import my dataset in R using read.table():

Dataset.df <- read.table(\"C:\\\\dataset.txt\", header=TRUE)

But

11条回答
  •  隐瞒了意图╮
    2020-11-28 22:17

    One of my variables was categorical with one alternative being multi string ("no event"). When I used read.table, it assumed that the space after the first string meant the end of the data point and the second string was pushed to the next variable. I used sep= "\t" to solve the problem. I was using RStudio in a Mac OX environment. A previous solution was to transform .txt files to .csv in Excel, and afterwards open them with read.csv function.

提交回复
热议问题