I am using the deaths
file from chapters 5.2 and 5.3 of the Mastering Metrics data that can be found here. I am trying to group pop
by state and year and return the mean pop
. I have tried several methods but when I merge the group the results do not look proper.
mlda <- read.dta("C:/Users/perdue/Desktop/Adv.MicroEconometrics/HA 8/deaths.dta") ## reading in my data
mlda$avg.pop <- aggregate(mlda[, 7], list(mlda$state), mean)
Error in `$<-.data.frame`(`*tmp*`, avg.pop, value = list(Group.1 = c(1L, :
replacement has 51 rows, data has 24786