0

I have a data frame with columns

full_name   flag
XYZ yes
XYZ missing
XYZ yes
ABC yes

I first want to group by full_name, find the sum of flag values and then count no of 'yes' expected output -

full_name flag num den
XYZ yes 2 3
XYZ missing 2 3
XYZ yes 2 3
ABC yes 1 1

I have tried using summarize but it groups the names and gives the sum - I want the sum value to be added for each row. Any ideas? Thank you

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
  • It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Aug 24 '22 at 21:25
  • 1
    `summarize()` gives one row per group, `mutate()` adds columns with the same number of rows. – Gregor Thomas Aug 24 '22 at 21:26

0 Answers0