I have the following database
Clientes.Dep..Gratuito.PCG Clientes.Dep..Gratuito Clientes.Dep..Não.Gratuito
0 0 0
0 0 0
25 0 0
0 0 2
0 0 79
0 0 71
Clientes.Usu..Gratuito.PCG Clientes.Usu..Gratuito Clientes.Usu..Não.Gratuito
21 0 0
50 0 0
0 0 0
58 0 1
0 0 0
0 0 16
What I want is to construct two variables Clientes.Dep
and Clientes.Usu
using the package dplyr
, and these columns would be the sum of everything involving Dep.
and Usu.
, respectively. An example of my attempts is
CLIENTES %>%
mutate(Clientes.Dep = rowSums(select(contains("Dep."))),
Clientes.Usu = rowSums(select(contains("Usu."))))
but without success.
Follow%% of data
structure(list(Clientes.Dep..Gratuito.PCG = c(0, 0, 25, 0, 0,
0), Clientes.Dep..Gratuito = c(0, 0, 0, 0, 0, 0), Clientes.Dep..Não.Gratuito = c(0,
0, 0, 2, 79, 71), Clientes.Usu..Gratuito.PCG = c(21, 50, 0, 58, 0, 0),
Clientes.Usu..Gratuito = c(0, 0, 0, 0, 0, 0), Clientes.Usu..Não.Gratuito = c(0,
0, 0, 1, 0, 16)), .Names = c("Clientes.Dep..Gratuito.PCG", "Clientes.Dep..Gratuito",
"Clientes.Dep..Não.Gratuito", "Clientes.Usu..Gratuito.PCG", "Clientes.Usu..Gratuito",
"Clientes.Usu..Não.Gratuito"), row.names = c(NA, 6L), class = "data.frame")