Debutant
Debutant

Reputation: 357

Is read.table() intolerant to missing data?

I try to import the following data set into R using read.table function:

Gender  Age     target-TAA  Survival(mo)
1   59  IL13Ra2 6
1   63  EGFRvIII    5
2   71  IL13Ra2 12
1   67  CD133   4
2   48  EGFRvIII    10
1   78  CD133   6
1   65  IL13Ra2 5
2   65  IL13Ra2 7
1   73  EGFRvIII    2
2   78  EGFRvIII    
1   56  IL13Ra2 14
1   67  CD133   7
2   69  CD133   9
2   43  IL13Ra2 6
2   58  EGFRvIII    
1   61  CD133   3
1   60  IL13Ra2 5
2   75  EGFRvIII    13
2   66  EGFRvIII    7

Now, there are 3 missing data, I keep getting the following error:

Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  : 
  line 2 did not have 5 elements

And this error pops up referring to different lines with missing files. How can I fix this without having to change my data set?

Upvotes: 1

Views: 30

Answers (1)

akrun
akrun

Reputation: 887048

We can use read.table with fill = TRUE

df1 <- read.table('file.csv', fill = TRUE)

Upvotes: 1

Related Questions