Not able to read missing values using read.table

r

#1

Hi
I have tried code which was mentioned in toturial and also tried below code in R but still it is not showing any missing values but when I go see my CSV I can missing values, can some please advise what I doing wrong.
ile1 = 'C:/Users/padalav/Desktop/ds sample2/testset.csv' file2 = 'C:/Users/padalav/Desktop/ds sample2/trainset.csv' testdata <- read.table(file=file1, header=TRUE, sep=",",na.strings = "NA",fill=TRUE,quote='') traindata <- read.table(file=file2, header=TRUE, sep=",",na.strings = "NA",fill=TRUE,quote='')


#2

Hi @venkateshpadala

You are actually missing out on highlighting the blank values while loading data files. Use this code:

> testdata <- read.table(file=file1, header=TRUE, sep=",",na.strings = "NA",""," ",fill=TRUE,quote='') 
> traindata <- read.table(file=file2, header=TRUE, sep=",",na.strings = "NA",""," ",fill=TRUE,quote='')
> table(is.na(traindata))
> table(is.na(testdata))

Hope this helps.


#3

I tried it but it is giving me below error.
Error in match.arg(numerals) :
‘arg’ should be one of “allow.loss”, “warn.loss”, “no.loss”


#4

@venkateshpadala: You should use read.csv: Please use the code below.

 > testdata <- read.csv(file=file1, header=TRUE, sep=",",na.strings = "NA",""," ",fill=TRUE,quote='') 
 > traindata <- read.csv(file=file2, header=TRUE, sep=",",na.strings = "NA",""," ",fill=TRUE,quote='')
 > table(is.na(traindata))
 > table(is.na(testdata))

#5

I am also not getting any missing values.
The data has 32561 rows and 12 column so the table(is.na(train)) should addup allthe values :-
32561x12 = 390732
while in tutorial :-
419031+4262=423293

In fact in the last command:

CrossTable(train$Sex,train$Income.Group)

we got output:
Total Observations in Table: 32561
so I feel 390732=32561x12 value is correct.
Please guide me if there is any error.


#6

Try this:-
train <- read.csv(“train_gbW7HTd.csv”,header = TRUE,na.strings = " ")


#7

traindata <- read.csv(file=file1, header=TRUE, sep=",",na.strings = c(“NA”,""," "))
table(is.na(traindata))


#8

Instead of getting this …

      False  
      419031

I get

What’s the reason behind this ??
Plz share your solution.
Thanks.


#10

I am taking the same tutorial. Dont worry about the count. The count was from an old train file used for the last tutorial. Your count is correct!