I know this is super simple, but I always have trouble with this.
site     diagnosis    week   value
Site A   anxiety      total  13
Site B   anxiety      total  1
Site A   depression   total  27
Site C   depression   total  18
I want to get the data in a state where I can plot it by diagnosis. I don't care about site or week, just want the sum of all values for each diagnosis.
I have tried
df %>% 
  group_by(diagnosis) %>% 
  summarize(
    total = sum(value, na.rm = TRUE))
But I get the error
"Error in
summarize():
! Problem while computingtotal_value = sum(n, na.rm = TRUE).
ℹ The error occurred in group 1: diagnosis = "anxiety".
Caused by error insum():
! invalid 'type' (closure) of argument
Runrlang::last_error()to see where the error occurred."
 
    