I have a dataframe like this:
df <- data.frame( SchoolID=c(\"A\",\"A\",\"B\",\"B\",\"C\",\"D\"), Country=c(\"XX\",\"XX\",\"XX\",\"YY\"
One approach, which does not rely on third-party libraries:
> as.data.frame(rowSums(table(df[!duplicated(df), ]), na.rm=T)) rowSums(table(df[!duplicated(df), ]), na.rm = T) A 1 B 2 C 1 D 1