Error in Ops.factor(): level sets of factors are different

I am using the code below to count how many time the id appears in the manager_id column :-

  mutate(ManagerCount = map_int(.x = WpA_Rscript$id,
                                        .f = ~ sum(WpA_Rscript$manager_id == .x,
                                                   na.rm = TRUE)))

However when I use this code i get the following error:-

Error in Ops.factor(WpA_Rscript$manager_gpid, .x) : 
  level sets of factors are different

Can anyone help me to understand what the issue is here?

KInd regards,
Forrestgump

3 posts were merged into an existing topic: Creating COUNTIF equivalent in R