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
If I'm understanding correctly, you're just basing this on fdate? If your dataframe is piglets, try this:
piglets
piglets$litter <- as.numeric(factor(piglets$fdate))