Missing Data In R :-
In R, missing values are represented by the
symbol NA (not available).
R uses the same symbol for character and numeric data.
Ex.
> x=NA
> print(x)
[1] NA
> y=c(1,2,3,NA)
> print(y)
[1] 1 2 3 NA
Testing for Missing Values:-
[Link] detect the missing observation .
It gives a logical value . TRUE OR FALSE.
Ex.
> a= NA # returns TRUE of a is missing
> [Link](a)
[1] TRUE
> b=c(1,2,3,4,NA) # returns a vector (F F F F T)
> [Link](b)
[1] FALSE FALSE FALSE FALSE TRUE
NOTE := NA and NULL both are not same thing .
NA -> Placeholder for some missing value .
NULL -> Something never existing at all .
Mean with the missing value :-
Arithmetic functions on missing values yield missing
values.
Calculating mean with missing values is not possible it will
generate error .
Ex.
>b
[1] 1 2 3 4 NA
> mean(b)
[1] NA
Excluding Missing Values from Analyses :-
To exclude missing value we will use an argument [Link]
=TRUE , it takes a logiacal value ,TRUE for removing
missing value.
Ex.
> a=c(1,2,3,NA,5,6,7,NA,NA)
>a
[1] 1 2 3 NA 5 6 7 NA NA
> mean(a,[Link]=T) (1+2+3+5+6+7)/6 =4
[1] 4
Thank you