R NA Values

NA Values

NA implies ‘Not Available’ or ‘Missing Data’. Any Operations done on NA will result in NA.

Consider a student dataset, std

NA Values output in r language

If we want the average age of the class or total weight of the class

CODE/PROGRAM/EXAMPLE
mean(std$Age)
	[1] NA

	sum(std$Weight)
	[1] NA
	
		//The results are NA

To get the result even with NA in some fields use the option ‘na.rm=TRUE’

CODE/PROGRAM/EXAMPLE
mean(std$Age, na.rm = TRUE)
	[1] 17.5

	sum(std$Weight, na.rm = TRUE)
	[1] 369"),
array("syntax","//Syntax:
	is.na(x)
		
		where x is the dataset
		it checks if NA exists in the object or not
	
	std$Age
	[1] NA NA 17 16 18 19

	is.na(std$Age)
	[1] TRUE TRUE FALSE FALSE FALSE FALSE

na.omit()

it omits the entire row Consider the std data frame.

na.omit() function output 1

To omit the entire row with NA values use na.omit()

Syntax
na.omit(std)

Output:

na.omit() function output 2
#NA_Values_in_r_language #na.omit()_function_in_r_language #na.omit()_function_in_programming

(New page will open, for Comment)

Not yet commented...