I have a dataset with many missing values. Some missing values ββare NA, some are Nulls, and others have different gap lengths. I would like to use the function freadin Rto read all these values ββas missing.
Here is an example:
iris <- data.table(iris)[1:5]
iris[1,Species:=' ']
iris[2,Species:=' ']
iris[3,Species:='NULL']
write.csv(iris,file="iris.csv")
fread("iris.csv",na.strings=c("NULL"," "))
V1 Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1: 1 5.1 3.5 1.4 0.2
2: 2 4.9 3.0 1.4 0.2 NA
3: 3 4.7 3.2 1.3 0.2 NA
4: 4 4.6 3.1 1.5 0.2 setosa
5: 5 5.0 3.6 1.4 0.2 setosa
In the above example, we see that I can not account for the first missing value, since there are many spaces. Does anyone know a way to account for this?
source
share