I'm new at r and this website. I have copied a sample of my data below. Basically, I have data that has 29 variables/columns and I have 30 unique row values. I want to aggregate over all the columns that are not community (all but one column). Is there a simpler way to do this? I was going to use:
newdf <- aggregate (Column 1 + Column 2 + Column 3 .... Column 29 ~ Community, df, sum)
However this is rather tedious and prone to mistakes. Is there another way to do this? Sorry if this has been asked before I couldn't find another post.
Community, Total.Pop., Female.Pop., Male.Pop., White.Alone.
Aleutians, 2697, 1750, 947, 64
Aleutians, 1182, 6831, 499, 2952
Aleutians, 4283, 2830, 1453, 1893
Anchorage, 4835, 2477, 2358, 4186
Anchorage, 4472, 2278, 2194, 3968
This is what I would ideally like:
Community, Total.Pop., Female.Pop., Male.Pop., White.Alone.
Aleutians, 8162, 11411, 2899, 4909
Anchorage, 9307, 4755, 4552, 8154