I am new to R and need to know how to keep the variable 'gender' at its constant mean in order to make a prediction after using a Poisson regression analysis on data about doctor visits. This is a sample of my data:
visits gender    illness    age.category
   1 female       1          <30
   1 female       1          <30
   1   male       3          <30
   1   male       1          <30
   1   male       2          <30
   1 female       5          <30
   1 female       4          <30
   1 female       3          <30
   1 female       2          <30
   1   male       1          <30
I have been given the example (see below) of how to predict rates of visits to a doctor over a two week period for men and for women (whilst holding age and illness at constant means).
sex <- factor(c('female', 'male',))
avg.age <- mean(DoctorVisits$age)
avg.illness <- mean(DoctorVisits$illness)
hypothetical.person <- expand.grid(age=avg.age,
                               gender=sex,
                               illness=avg.illness)
predict(M.dr, 
    newdata = hypothetical.person,
    type = 'response')
But I need to predict rates of visits to a doctor over a two week period for age groups (whilst holding sex and illness at their constant means). Yet, I do not know how to keep gender at its constant mean. How do I ensure this?
                        
Here is how I would create a data.frame for all different
illnesslevels according to male and female and their average illness.