NAsummary: Summarize NA values in a matrix or data.frame (or data.table)

Description Usage Arguments Details Author(s) Examples

View source: R/NAsummary.R

Description

Summarize the available information in a data.frame (or similar) quickly

Usage

1
NAsummary(df, include_nan = FALSE)

Arguments

df

A data.frame to be summarized

include_nan

Do you want to also see Nan's along with NA's Defaults to FALSE

Details

For a data frame, data.table, or matrix this function creates a summary of how many NA's and unique values there are in each column. Useful for a quick summary of how complete your data is, and can be useful to pass to other commands; for example to remove columns that only have one unique value.

Author(s)

Gene Leynes

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 ## Create an example data frame:
	set.seed(100)
	df <- data.frame(ID = 1:30,
					 col1 = sample(c(rep(NA, 5), rpois(25, 7))),
					 col2 = sample(letters[1:5], replace=TRUE),
					 col3 = sample(letters[1:5], replace=TRUE),
					 col4 = NA,
					 col5 = "OneValue",
					 col6 = sample(letters[1:5], replace=TRUE))
	## Create a summary:
	MySummary <- NAsummary(df)
	MySummary
	## Columns with only one unique value:
	rownames(MySummary)[MySummary$nUnique == 1]
	## Columns with 100% NA values:
	rownames(MySummary)[MySummary$rNA == 1]

geneorama/geneorama documentation built on Oct. 17, 2020, 12:35 a.m.