I'm trying to count the number of visits a provider has conducted if the visit meets a qualification in R. In the commented out phrase, I can get each provider with the correct number of total visits, but when I try to set an if statement, I'm getting the provider repeated multiple times and not the correct visit count.
TeleHealth_Counts %>%
group_by(TeleHealth_Counts$`Visit Provider`) %>%
summarize(Video_Count = ifelse(`Type` == "Video Visit New", NA, sum(`Visit Count`, na.rm = TRUE)))
#summarize(Tele_Count = sum(`Visit Count`, na.rm = TRUE))
The other issue I'm facing is that when I assign this code to a variable so I can download the data, I'm getting an error: summarise()
regrouping output by 'TeleHealth_Counts$Visit Provider
' (override with .groups
argument). How do I overcome this error or download the data frame I'm seeing in my console?
I've tried assigning it to a variable, to Tele_Count and to the data frame df_phys with the code below.
physicians <- unique(TeleHealth_Counts$`Visit Provider`)
df_phys <-data.frame(physicians)