I'm using dcast to swing some rows into columns
My data looks like this:
Place, Above.or.Below.Povertyline, Sex, Population Total
Haines, Above, Male, 55
Haines, Above, Female,7
Haines, Below, Male,0
Haines, Below, Female,7
Halibut, Above, Male,0
Halibut, Above, Female,0
I used this command to dcast which gives me the following error:
df1 <- dcast(df, Place+ Above.or.Below.Povertyline ~ Sex, value.var = "Population Total")
Error: Aggregation function missing: defaulting to length
It gives me the following dataset which looks kinda right... except for the 8s. I think its duplicates? but I'm not sure if I can format the function better.
Community, Above.or.Below.Povertyline, Female, Male
Haines, Above, 8, 8
Haines, Below, 8, 8
Halibut, Above, 8, 8
Halibut, Below, 8, 8