I'm trying to group two variables and sum one of them based on the previous grouped variable.
structure(list(`Tipo de Geração` = c("EOL", "EOL", "EOL", "EOL",
"EOL", "EOL", "EOL", "EOL", "EOL", "UFV", "UFV", "UFV", "UFV",
"UFV", "UFV", "UFV", "UFV", "UFV", "UTE", "UTE", "UTE", "UTE",
"UTE", "UTE", "UTE", "UTE", "UTE", "UTE", "UTE", "UTE", "UTE",
"UTE", "UTE"), UF = c("PI", "PI", "PI", "RN", "RN", "RN", "RN",
"RN", "RS", "PB", "PB", "PB", "PB", "PB", "PB", "PB", "PB", "PB",
"SP", "AM", "AM", "AM", "AM", "AM", "AM", "AM", "AM", "AM", "AM",
"AM", "AM", "AM", "AM"), Usina = c("Ventos de Santa Angela 14",
"Ventos de Santa Angela 14", "Ventos de Santa Angela 14", "Vila Maranhão III",
"Vila Maranhão III", "Vila Maranhão III", "Vila Maranhão III",
"Vila Maranhão III", "Xangri-lá", "Coremas III", "Coremas III",
"Coremas III", "Coremas III", "Coremas III", "Coremas III", "Coremas III",
"Coremas III", "Coremas III", "Branco Peres", "Alvarães - CGA",
"Alvarães - CGA", "Alvarães - CGA", "Alvarães - CGA", "Alvarães - CGA",
"Alvarães - CGA", "Alvarães - CGA", "Alvarães - CGA", "Alvarães - CGA",
"Alvarães - CGA", "Alvarães - CGA", "Tamaniquá - CGA", "Tamaniquá - CGA",
"Tamaniquá - CGA"), UG = c(12, 13, 14, 5, 6, 7, 8, 9, 10, 1,
2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
1, 2, 3), `Potência UG (kW)` = c(3000, 3000, 3000, 3550, 3550,
3550, 3550, 3550, 3800, 3000, 3000, 3000, 3000, 3000, 3000, 3000,
3000, 3000, 15000, 352, 352, 352, 352, 352, 352, 352, 352, 352,
352, 352, 297, 297, 297)), row.names = c(NA, -33L), class = c("tbl_df",
"tbl", "data.frame"))
The variable "UG" stands for the number of eletric turbines which have the following potency represeted by the Potência UG (kW)
variable. The variable Usina (Hydroelectric power plant) can have multiple UGs values and also have multiple potencys values. Therefore, I need to group the number of UGs and perform a sum operation of all the following Potência UG (kW)
values for each Hydroelectric power plant (represented by the Usina variable). How can i do this?
Thanks!