data.table filter and count uniques

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

dt[Class == 1, .(un_val1 = uniqueN(Value1))]

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top