mercredi 23 août 2017

How to calculate the number of missing values ​using if function in R?

In R, I use the if, is.na and rowSums function to find the number of missing observations per condition and try to remove 100 observations in the largest order.

I would like to know the number of missing values ​​in an observation where the variable a is 1 and the variable b is 1. And I want to remove the observations from the raw data in the order of the largest missing values.

How to make that code in R?

I tried and I made this code. As using it, I can get number of missing value. But can't get as condition.(a is 1 and b is 1)

df<-read.csv("lastfile.csv", header = TRUE)

df[,][df[,]==999999999]<-NA
df[,][df[,]==-999999999]<-NA

rowdf<-rowSums(is.na(df))

please help me..

Aucun commentaire:

Enregistrer un commentaire