dt_percent_not_na {libbib} | R Documentation |
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
dt_percent_not_na(DT, acolumn)
DT |
A data.table object |
acolumn |
a quoted column name |
Returns percentage of non-NA instances in column
mt <- as.data.table(mtcars)
mt[mpg<16, mpg:=NA]
dt_percent_not_na(mt, "mpg") # 68.75