0

I have a large dataset containing rows (GP-practices) and columns (one for each combination of ICPC_code, agegroup and prescription) for example R74|65_75|J01CA04 and R74|75_plus|J01CA04 now i want to sum them to R74|65_plus|J01CA04.

I tried the mutate function:

df1 <- df %>%
   mutate("R74|65_plus|J01CA04" = "R74|65_75|J01CA04" + "R74|75_plus|J01CA04")

but it didn't work as there was an error 'non numeric argument to binary operator' The column contains counts so the amount of patients and so only numbers. The column type is numeric.

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • 3
    Mutate expects unquoted column names. Your column names are non-standard since they have special characters in them, so you will need to surround them in backticks, `mutate(\`R74|65_plus|J01CA04\` = \`R74|65_75|J01CA04\` + \`R74|75_plus|J01CA04\`)` – Gregor Thomas Jul 31 '23 at 14:17

1 Answers1

0

you could try this, use ` instead of " for your selecting your variables.

Joan
  • 30
  • 4