I want to identify missing values in an R data datable
In order to get the id, column "id" of each column in your dataset
I use apply(is.na(dt_tb) 2, which)
this scrip tells me the position, I would like to replace the position by the id number (id column)
dt_tb <- data.table(id = c(5, 6, 7, 15),
coll = c("this", NA,"NA", "text"),
cyy = c(TRUE, FALSE, TRUE, TRUE),
hhh = c(2.5, 4.2, 3.2, NA),
stringsAsFactors = FALSE)
apply(is.na(dt_tb), 2, which)
example $id integer(0)
$coll [1] 2
$cyy integer(0)
$hhh [1] 4
I want
id integer(0)
coll 6 7
cyy integer(0)
hhh 15