I am new to R and started exploring na.strings = c()
function along with read.csv
.
I have read that using this option, all the missing values will be replaced to NA but I don’t see that happening in my files. I don’t see any difference in the output despite using na.strings = c()
. Please help if I am missing something. In both the cases, I see NA when numeric value is missing but not when char value is missing. So, what is the use of using this function?
Here is my sample csv file:
Char,Numeric
A,3
B,
,5
And my code:
DF_withoutNA = read.csv("filepath/R_NA.csv",header = TRUE)
DF_with = read.csv("filepath /R_NA.csv",header = TRUE,
na.strings = c("Char","Numeric"))
head(DF_withoutNA)
Char Numeric
1 A 3
2 B NA
3 5
head(DF_with)
Char Numeric
1 A 3
2 B NA
3 5