Identifying or coding unique factors

后端 未结 1 910
鱼传尺愫
鱼传尺愫 2020-12-12 04:26

I would like to create a new variable,litter, to indicate each sow or litter in different farrowing dates (fdate). Each litter is to be numbered from 1 to N with an increame

相关标签:
1条回答
  • 2020-12-12 04:54

    If I'm understanding correctly, you're just basing this on fdate? If your dataframe is piglets, try this:

    piglets$litter <- as.numeric(factor(piglets$fdate))
    
    0 讨论(0)
提交回复
热议问题