Basically what I need to perform is to transform my country variables into per capita terms, i.e. divide all values by the country's population.
So I have df
:
country <- c("A","B","C","D")
income <- c(10,20,30,40)
cars <- c(100,200,300,400)
df <- data.frame(country,income,cars)
And I want to divide all columns by dfpop$pop
pop <- c(1,2,3,4)
dfpop <- data.frame(country,pop)
any ideas?