Hello,
Iβve created the following age categories on a data set that contains death data
Order = case_when(
age == "0 to 4 years" ~ 1,
age == "05 to 9 years" ~ 2,
age == "10 to 14 years" ~ 3,
age == "15 to 19 years" ~ 4,
age == "20 to 24 years" ~ 5,
age == "25 to 34 years" ~ 6,
age == "35 to 44 years" ~ 7,
age == "45 to 54 years" ~ 8,
age == "55 to 59 years" ~ 9,
age == "60 to 64 years" ~ 10,
age == "65 to 74 years" ~ 11,
age == "75 to 84 years" ~ 12,
age == "85 and older" ~ 13,
age == "Under investigation" ~ 14))
I am calculating age-adjusted rates for opioid overdose deaths for these categories for years 2015-2023. The problem I am having is that when there is no data in some of the categories, the age category is dropped for a particular year. For example, in the year 2015, all age categories have values in them so all categories show in the output. However, for other years, there arenβt deaths for all the age categories listed, so R omits the age category instead of putting a 0 or NA in it.
Can anyone point out something I can do so that all age categories show despite there being no data in them? The reason I need them to show is because I need to add population data to the data frame for each category but I get an error message that tells me that the rows donβt match the number of data I am trying to add because some age categories got dropped for not having values in them.
Thank you