I am reading a csv file into r (with the blank.lines.skip=T
option). It has some character,numeric, and factor variables. When r reads the file in, some cells are given NA's while others are left blank. It appears that only columns with all numeric data are given NA while columns with other types of data are left blank. My data set is too large to check all of this by hand. I have many columns and rows in my data, and am not sure why some cells are getting the NA and others aren't, unless it is by design. Any advice is appreciated. Cheers.
Asked
Active
Viewed 2,839 times
0

user27008
- 600
- 3
- 15
- 24
-
2Could you please you provide a reproducible example? – Maxim.K Apr 24 '13 at 14:47
-
3Here's how to provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). What R function are you using? Can you find some lines in your file where you see `NA` or blank and show us the lines next to the R output? – Blue Magister Apr 24 '13 at 14:48
-
Sorry for no example. eddi's answer confirms what I was thinking and found from some test data I made and used `read.table` on. – user27008 Apr 24 '13 at 15:05
1 Answers
5
When expecting a number in a cell and not finding it read
's would assign a type-appropriate NA
to that cell. If instead expecting a string (or a factor), an empty cell is a valid entry , thus no NA's.
So NA
's will only be in numeric class columns, but not in character or factor class ones.

eddi
- 49,088
- 6
- 104
- 155