Learn R Programming

libbib (version 1.6.4)

dt_percent_not_na: Return the percentage of non-NA instances in a data.table column

Description

This function takes a data.table and a quoted column name and returns the percentage of the data in the column that is not NA. The percent is out of 100 and contains up to two decimal places

Usage

dt_percent_not_na(DT, acolumn)

Value

Returns percentage of non-NA instances in column

Arguments

DT

A data.table object

acolumn

a quoted column name

See Also

Examples

Run this code

mt <- as.data.table(mtcars)
mt[mpg<16, mpg:=NA]
dt_percent_not_na(mt, "mpg")         # 68.75

Run the code above in your browser using DataLab