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.
here is what I have so far
library(tidyverse) library(dplyr) df <- read.csv("C:/Users/brand/Desktop/house.csv") names(df) summary(df) df$vote_D dem_pct <- 100*df$vote_D/(df$vote_D+df$vote_R) mean(dem_pct)
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.