I have this df:
test <- structure(list(tipo_prestacion = c("TAC", NA, NA, "RESONANCIA MAGNÉTICA",
NA, NA, "ECOGRAFÍA", NA, NA, "MAMOGRAFÍA", NA, NA), tipo_cita = c("1 (LE Estructural)",
"2 (Aplaz. voluntario)", "3 (Aplaz. clinico)", "1 (LE Estructural)",
"2 (Aplaz. voluntario)", "3 (Aplaz. clinico)", "1 (LE Estructural)",
"2 (Aplaz. voluntario)", "3 (Aplaz. clinico)", "1 (LE Estructural)",
"2 (Aplaz. voluntario)", "3 (Aplaz. clinico)"), h_territ = c(113,
17, 517, 402, 11, 1150, 370, 18, 1041, NA, NA, 35), region = c(3614,
2924, 2504, 3724, 2965, 11146, 10369, 3382, 9647, 797, 172, 581
)), row.names = c(NA, -12L), class = c("tbl_df", "tbl", "data.frame"
))
where tipo_prestacion, tipo_cita, h_territ and region are four columns with four types of medical tests (TAC, RESONANCIA MAGNETICA, ECOGRAFIA, MAMOGRAFIA) that have each three type of citations (1,2,3 with his respectives names). I want to obtain the sum of each medical test (including all type of his citations) for h_territ and region and add it to a new row, called 'Total'.