library(dplyr) duck <- data.frame(n = c(48, 47, 41, 39, 32, 28, 25, 24), died = c(1, 2, 2, 5, 4, 3, 1, 1), lived = c(47, 45, 39, 34, 28, 25, 24, 23)) # you can add variables with mutate, and you can use the new variables # below in the same mutate statement to create other variables # Add what you need to 'duck' with additional lines to the 'mutate' statement # that replace the '...' currently there # NOTE: you can learn more about dplyr on datacamp and the web. # '%>%' pipes the data into the statements that follow duck <- duck %>% mutate(p_hat = lived/n, var_p_hat = p_hat * (1 - p_hat) / n, ...) # use the 'summarise' function from 'dplyr' to calculate key totals totals <- duck %>% summarise(n = sum(n), died = sum(died), lived = sum(lived)) # complete the 'mutate' statement to calculate necessary variables on totals # by replacing the '...' currently there with the necessary commands totals <- totals %>% mutate(...)