Just to throw in another dplyr-flavored approach:
library(dplyr)
distinct(Data) %>% count(Tid)
#Source: local data frame [4 x 2]
#
# Tid n
#1 1 1
#2 2 2
#3 3 1
#4 4 2
(Not suggesting this to be faster than other dplyr/data.table solutions.)
re @David's comment, all proposed solutions get to basically the same result. But of course, my suggestion is not identical with table(unique(Data)$Tid)
. It's faster and returns a data.frame (not a table
object).