dt_na_breakdown {libbib} | R Documentation |
Get a breakdown of the NA-status of a column in a data.table
Description
This function takes a (quoted) column to group by, and tabulates
the count of how many of those values are not-NA and NA, and adds
the percent of occurrences. A TRUE
in the first output
column means the data is _not_ missing; FALSE
corresponds
to missing.
Usage
dt_na_breakdown(DT, acolumn, big.mark = FALSE)
Arguments
DT |
The data.table object to operate on |
acolumn |
a quoted column name |
big.mark |
If |
Details
The final row is a total count
The quoted group-by variable must be a character or factor
Value
Returns a data.table with three columns: the not-NA status of the column specified, a count column, and a percent column (out of 100) to two decimal places
Examples
iris_dt <- as.data.table(iris)
iris_dt[sample(1:.N, 10), Species:=NA_character_]
dt_na_breakdown(iris_dt, "Species")
[Package libbib version 1.6.4 Index]