How to remove NA values using R Programming

Suppose that you got a csv file namely newedata.csv contains those following data.  


    Ozone Solar.R Wind Temp Month Day
1      41     190  7.4   67     5   1
2      36     118  8.0   72     5   2
3      12     149 12.6   74     5   3
4      18     313 11.5   62     5   4
5      NA      NA 14.3   56     5   5
6      28      NA 14.9   66     5   6
7      23     299  8.6   65     5   7
................................................
................................................
................................................
148    14      20 16.6   63     9  25
149    30     193  6.9   70     9  26
150    NA     145 13.2   77     9  27
151    14     191 14.3   75     9  28
152    18     131  8.0   76     9  29
153    20     223 11.5   68     9  30

So how to remove NA values or to know how many NA values  are in your newdata.csv file or its specific row or column

To Removes NA values From entire data set First Load newdata.csv in your R program



Type this command to remove NA values from entire file

x[!(is.na(x))]

To Removes NA values From specific column. Here we remove NA values from column 1 in newdata.csv


x[,1][!(is.na(x[,1]))]

To Removes NA values From specific row. Here we remove NA values from row 1 in newdata.csv


x[1,][!(is.na(x[1,]))]

How to find number of NA values in entire newdata.csv

x[is.na(x)]

How to find number of NA values specific column in newdata.csv. Here we find out number of NA values in column 1

 x[,1][is.na(x[,1])]

How to find number of NA values specific row in newdata.csv. Here we find out number of NA values in row 1

Comments

Popular posts from this blog

পিৎজা এবং বই

How to Download Video from Youtube - The Easiest way