I have a large dataset that includes a breakdown of revenue and expenditure for each county in the US. There is a column (Type) that includes codes for the type of revenue or expenditure. I need to sum the total dollar amount (Flow) for each county for the total revenue and total expenditure. I have been trying to do with the following code and keep getting this error: Error in FUN(X[[I]], ...) : only defined on a data frame with all numeric-alike variables. Is there a way around this error or another way of doing what I want to do? Thanks in advance for your help!
Data linked here.
county2013$Expenditures <- county2013 %>%
group_by(FIPS) %>%
sum(county2013[which(county2013$Type == 'B01' | county2013$Type == 'B21' | county2013$Type == 'B01' | county2013$Type == 'B21' | county2013$Type == 'B22' | county2013$Type == 'B30' | county2013$Type == 'B42' | county2013$Type == 'B46' | county2013$Type == 'B50' | county2013$Type == 'B59' | county2013$Type == 'B79' | county2013$Type == 'B80' | county2013$Type == 'B89' | county2013$Type == 'B91' | county2013$Type == 'B92' | county2013$Type == 'B93' | county2013$Type == 'B94' | county2013$Type == 'C21' | county2013$Type == 'C30' | county2013$Type == 'C42' | county2013$Type == 'C46' | county2013$Type == 'C50' | county2013$Type == 'C79' | county2013$Type == 'C80' | county2013$Type == 'C89' | county2013$Type == 'C91' | county2013$Type == 'C92' | county2013$Type == 'C93' | county2013$Type == 'C94' | county2013$Type == 'D21' | county2013$Type == 'D30' | county2013$Type == 'D42' | county2013$Type == 'D46' | county2013$Type == 'D50' | county2013$Type == 'D79' | county2013$Type == 'D80' | county2013$Type == 'D89' | county2013$Type == 'D91' | county2013$Type == 'D92' | county2013$Type == 'D93' | county2013$Type == 'D94' | county2013$Type == 'T01'| county2013$Type =='T09' | county2013$Type =='T10' | county2013$Type == 'T11' | county2013$Type == 'T12' | county2013$Type == 'T13' | county2013$Type == 'T14' | county2013$Type =='T15' | county2013$Type == 'T16' | county2013$Type == 'T19'| county2013$Type == 'T20' | county2013$Type == 'T21' | county2013$Type == 'T22' | county2013$Type == 'T23' | county2013$Type == 'T24' | county2013$Type == 'T25' | county2013$Type == 'T27' | county2013$Type == 'T28' | county2013$Type == 'T29' | county2013$Type == 'T40' | county2013$Type == 'T41' | county2013$Type == 'T50' | county2013$Type == 'T51' | county2013$Type == 'T53' | county2013$Type == 'T99' | county2013$Type == 'A01' | county2013$Type == 'A03' | county2013$Type == 'A09' | county2013$Type == 'A10' | county2013$Type == 'A12' | county2013$Type == 'A16'| county2013$Type == 'A18'| county2013$Type == 'A21' | county2013$Type == 'A36' | county2013$Type == 'A44' | county2013$Type == 'A45' | county2013$Type == 'A50' | county2013$Type == 'A56' | county2013$Type == 'A59'| county2013$Type == 'A60'| county2013$Type == 'A61'| county2013$Type == 'A80'| county2013$Type == 'A81'| county2013$Type == 'A87'| county2013$Type == 'A89' | county2013$Type == 'U01' | county2013$Type == 'U11' | county2013$Type == 'U20' | county2013$Type == 'U21' | county2013$Type == 'U30' | county2013$Type == 'U40' | county2013$Type == 'U41' | county2013$Type == 'U50' | county2013$Type == 'U95' | county2013$Type == 'U99' | county2013$Type == 'A90' | county2013$Type == 'A91' | county2013$Type == 'A92' | county2013$Type == 'A93' | county2013$Type == 'A94' | county2013$Type == 'X01' | county2013$Type == 'X02' | county2013$Type == 'X05' | county2013$Type == 'X08' | county2013$Type == 'Y01' | county2013$Type == 'Y02' | county2013$Type == 'Y04' | county2013$Type == 'Y11' | county2013$Type == 'Y12' | county2013$Type == 'Y51' | county2013$Type == 'Y52'), 5])