How to create a consecutive group number

后端 未结 8 1290
深忆病人
深忆病人 2020-11-21 16:13

I have a data frame (all_data) in which I have a list of sites (1... to n) and their scores e.g.

  site  score
     1    10
     1    11  
              


        
8条回答
  •  萌比男神i
    2020-11-21 16:59

    This should be fairly efficient and understandable:

    Dat$sitenum <- match(Dat$site, unique(Dat$site))  
    

提交回复
热议问题