Here, is an option with data.table
where we subset the rows by specifying logical expression in i
, then get the count of unique
values of the column ‘Value1’ with uniqueN
library(data.table)
dt[Class == 1, .(un_val1 = uniqueN(Value1))]
CLICK HERE to find out more related problems solutions.