2
I wonder if it has any function in the R that makes it possible to make a kind of "grouping" of the data. For example, a way to get this spreadsheet to return something like:
Codigo Grupo Qtde Total
3219 Vacina 3 293
Thanks in advance!
Test data:
dados <- data.frame(Codigo = c(3219, 3219, 3219, 3865, 3865, 3865),
Grupo = c('Vacina','Vacina','Vacina','Estética','Clínico','Clínico'),
Qtde = c(1, 1, 1, 19, 1, 1),
Total = c(58.00, 160.00, 75.00, 760.00, 170.00, 0.01))
Beatriz, good night! You can use the dplyr group_by:
dados %>% group_by(Codigo, Grupo)%>%
 summarise(Qtde = sum(Qtde, na.rm = T), Total = sum(Total, na.rm = T))
– lmonferrari
Perfect @lmonferrari’s answer. I just didn’t understand why the question was flagged out of scope. It’s probably a duplicate question...
– LuizZ
@Luizz For example, this question.
– Rui Barradas
Yes, that’s what I figured, @Rui. It’s a common question. That’s why I thought it should be flagged as duplicate, not as out of scope. Not to give the wrong signage to new users. But I do not know, it is only my opinion
– LuizZ