I get the following error:
Error in proxy[i, …, drop = FALSE] : incorrect number of dimensions
Please help. I can’t seem to figure out where I’m going wrong. Is my For Loop wrong? Or is my created variable named “output” being done incorrectly? Everything seems right until I get to my For Loop. Here’s my code:
ddi ← read_ipums_ddi(“cps_00026.xml”)
data ← read_ipums_micro(ddi)
data2 ← data%>%
rename_all(tolower)
data3 ← data2%>%
mutate(nh_white = if_else(race==100 & hispan==0, 1, 0),
nh_black = if_else(race==200 & hispan==0, 1, 0),
nh_api = if_else(race %in% c(651, 652) & hispan==0, 1, 0),
nh_other = if_else(!race %in% c(100, 200, 651, 652) & hispan==0, 1, 0),
latinx = if_else(hispan > 0 & hispan < 900, 1, 0),
wtfinl_six_mo = wtfinl/6
)
years ← c(2014,2015,2016,2017,2018,2019)
output ← vector(“double”, length(years))
for (i in seq_along(years)) {
data_filtered ← data3 %>%
#Filter for all Georgia entries where the source of public assistance income
#is not coded as not in Universe (0)
filter(srcwelfr == 1 & srcwelfr == 2 & srcwelfr == 3 &
year==years[i] & statefip == 13)
#Apply proper weights
table1 ← wtd.table(data_filtered$srcwelfr, weights = data_filtered$asecwth)
table1
Turn that table into a dataframe so that we can work with it
srcwelfr_year ← as.data.frame(table1)
srcwelfr_year ← reshape(srcwelfr_year, idvar = “status”, timevar = “Var1”, direction = “wide”)
print(srcwelfr_year)