Guest User

Untitled

a guest
Nov 20th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. agg <- aggregate(Valor ~ Filial, dados, sum)
  2. agg$Contagem <- tapply(dados$Filial, dados$Filial, FUN = length)
  3. agg <- agg[, c(1, 3, 2)]
  4. agg
  5. # Filial Contagem Valor
  6. #1 ABC 2 1512
  7. #2 JCT 2 610
  8. #3 XYZ 2 1170
  9.  
  10. dados <-
  11. structure(list(Filial = structure(c(1L, 3L, 3L, 2L, 2L, 1L), .Label = c("ABC",
  12. "JCT", "XYZ"), class = "factor"), Matrícula = c(100L, 200L, 100L,
  13. 300L, 300L, 300L), Valor = c(500, 850, 320, 512, 98, 1012)), .Names = c("Filial",
  14. "Matrícula", "Valor"), class = "data.frame", row.names = c(NA,
  15. -6L))
Add Comment
Please, Sign In to add comment