Reputation: 43
I screenshotted part of my table that I'm using in Rstudio. I want to combine the rows that have the same middle column value like "01020" and combine the 3rd columns' values together into one so the 01020 row would be 2 instead of 1. I don't care about retaining the 1st column. How would I do this?
Upvotes: 1
Views: 46
Reputation: 110
you can use (reshape2)
df2 <- dcast(df1, col1 ~ col2, value.var = "col3", fun.aggregate = sum)
Upvotes: 1