I have a data frame (I took an exemple from antoher post but it works for question)
library(data.table)
data = data.table(Category=c("First","First","First","Second","Third", "Third", "Second"),
Frequency=c(10,15,5,2,14,20,3))
And I'd like to sum by First and group all the other under the name of "Others" like this
data2 <- data.table(category = c("First", "Others"), Frequency = c(30,39))
How can I do this ? thank you
EDIT
I have edit my df and it looks like
data = data.table(Category=c("First","First","First","Second","Third", "Third", "Second"),
Frequency=c(10,15,5,2,14,20,3),
Bloc=c("B1","B2","B1","B1","B1","B2","B1")
)
How can I do in order to get
data2 <- data.table(category = c("First","First","Others" "Others"), Frequency = c(15,15,19,20), Bloc = c(B1,B2,B1,B2)
Thanks