I have 2 data-frames, one with 1093 observations containing data from every state over a time-span of n days, and the other data frame has 50 observations of 2 variables: state name and state populations. My ultimate goal is to create a percent of state population variable in the data-frame with 1093 observations. So my plan was to add the state populations to the data frame with 1093 observations by just matching up the state names. I tried this chunk of code:
df.state$population <- c(which(pop.states$State==df.state$state, pop.states$X2018.Population))
However, this did not work because there is a difference in lengths so my question is how can I add the population variable to this data-set or is there a different way for me to find the per capita measure of the variables found in the data-frame with 1093 observations? Thank you