Typescript Count Unique Values In R