Compute the number of distinct values in col2 for each distinct value in col1 in R

后端 未结 3 1922
清歌不尽
清歌不尽 2020-12-21 11:34

I have a dataframe like this:

df <- data.frame(
          SchoolID=c(\"A\",\"A\",\"B\",\"B\",\"C\",\"D\"),
          Country=c(\"XX\",\"XX\",\"XX\",\"YY\"         


        
3条回答
  •  既然无缘
    2020-12-21 12:18

    try this..

    select School,count(Country)
    from(
    select distinct School,Country
    from tbl_stacko) temp
    group by School
    

提交回复
热议问题