Hi everyone, I'm brand new to R but am trying to use TidyCensus.
I'm trying to find a way to calculate percentages of each variable to a variable in the table.
Is there any way to do this?
dec_race_var <- get_decennial(
geography = "county",
state = "TX",
county = "Harris County",
year = 2020,
variables = c(
"P2_001N",
"P2_005N",
"P2_006N",
"P2_002N",
"P2_008N",
"P2_007N",
"P2_009N",
"P2_010N",
"P2_011N")
)
head(dec_race_var)
This is my current code, it give me my variables I need but I want to find the percentage of P2_001N variable for all other variables. I was trying to add another column with only the P2_001N variable and run a row calculation but had no luck with only adding a row full of the P2_001N variable.
This is what I'm aiming to create.
Thanks for any help!