Description Usage Arguments Details Author(s) Examples
Summarize the available information in a data.frame (or similar) quickly
1 |
df |
A data.frame to be summarized |
include_nan |
Do you want to also see Nan's along with NA's Defaults to FALSE |
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.
Gene Leynes
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]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.