I am playing around with the us_rent_income data from tidyverse and I cannot figure how to convert the rows into columns
GEOID NAME variable estimate
01 Alabama income 24476
02 Alaska income 32940
02 Alaska variable 1200
04 Arizona variable 27517
04 Arizona variable 972
I would like to convert the variable column, into two different columns 'income' and 'variable', and convert the estimate value as the respective income and rent value as such:
GEOID NAME income rent
01 Alabama 24476 747
02 Alaska 32940 1200
04 Arizona 27517 972
I attempted to do
reshape(us_rent_income, idvar=c("NAME","GEOID"), timevar="variable", direction="wide")
but the data outputs with all NA