Hi everyone, I have to complete a problem set for a data science course I am enrolled in, and I am having a difficult time figuring out the code for calculating the mean of more than one variable.

I need to calculate the mean of dem_pct in which a Democratic incumbent, Republican incumbent is running, and when neither party has an incumbent running. The variables for these in the program are df$inc_D and df$inc_R. I understand this is a simple procedure, but I have had a difficult time finding the correct keywords for this search.

Thank you, but I need to find the mean of dem_pct when a Rep incumbent is running, a Dem incumbent is running and when neither has a candidate running. It seems that code wouldn’t take into consideration the dem_pct variable I created?