Why am I geting error: Column `BrLCI` must be length 46 (the group size) or one, not 0

Hello, I have written a long piece of code to get data and create confidence intervals using BinomCI. I'm not sure you want to see all that. I am attempting to create 2 additional columns for grouped indicators showing the confidence limits of a comparator but I get an error:

df <- df %>%

  • group_by(IndicatorNm) %>%
  • mutate(BrLCI = lwr.ci[geotype == "CCG"]) %>%
  • mutate(BrUCI = upr.ci[geotype == "CCG"])
    Error: Column BrLCI must be length 46 (the group size) or one, not 0

I have tried ungrouping as solutions suggest to do that but the error just changes to:
Error: Column BrLCI must be length 986 (the number of rows) or one, not 20

I have 20 groups (indicators).

The annoying thing is I have written another script to achieve the same ends and it works ok.
Any help gratefully received
Thanks

Hi, welcome!

We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.