Hi, I have following simple df:
source <- data.frame(
stringsAsFactors = FALSE,
Employee.ID = c("aaa",
"bbb","sss","ccc","fff","ffg","gedd"),
Age.Group = c("20-30",
"30-40","20-30","40-50","40-50","20-30",
"20-30"),
Action_Positivity = c(100, 0, 100, 0, 0, 100, 100),
Boundaries_Positivity = c(0, 0, 100, 100, 100, 0, 100),
Growth = c(3, 4, 2, 4, 5, 5, 5),
Career.Wellbeing_Positivity = c(100, 0, 0, 0, 0, 100, 100),
eSat_Positivity = c(0, 0, 100, 100, 100, 100, 100),
Technolory = c(2, 5, 3, 4, 4, 1, 5)
)
I am trying to create a new variable (Index) where all variables ending with "Positivity" would sum up so aaa should get 200, bbb 0...gedd 400. How can I do that? I know I should include
ends_with(match = "Positivity")
and
mutate_if
but I don't know how
Can you help?