Hello All,
I am in need of your help.
I cannot seem to find a direct scenario for what I am facing.
What I need to do is find the viral suppression rates by the sum and count to get a percentage and do a group_by with gender.
In this scenario, I have 3 columns: Gender, last quantitative lab value, and viral suppression numeric.
To explain further, the viral suppression numeric column was created with a case when based off of last quantitative lab value:
Demographic.Data <- Demographic.Data %>%
mutate(Viral_Suppression_Numeric = case_when(
Last.Quantitative.Lab.Value < 199 ~ "0",
Last.Quantitative.Lab.Value > 200 ~ "1",
T ~ NA_character_
))
that is how I have 3 columns.
The end result I would like is something along these lines, but by the viral suppression percentage and gender:
Male 34%
Female 57%
Transgender MTF 87%
I know to do this I would take the sum of viral suppression column and the count of viral suppression column and divide the two to get the percentage and then group by gender. However, I keep on having errors when I try.
one error I get is: x invalid 'type' (character) of argument
All the help is greatly appreciated.
below you will find a sample data set. I don't know how to make a reproduceable table yet. I apologize in advance as that is something I am learning.
gender last_quantitative_lab_value viral_suppression_numeric
Male 20 0
Male 20 0
Male 20 0
Male 22 0
Male 20 0
Female 20 0
Male 20 0
Male 20 0
Transgender MtF 1490 1
Female 1000 1
Male 20 0
Male 205 1
Male 20 0
Male 22 0
Male 208 1
Female 20 0
Female 201 1
Female 207 1
Transgender MtF 20 0
Female 1000 1
Thank you,
-Cody