Background
I have a dataset, df, where I would like to aggregate multiple columns and create a new column. I need to multiply Type, Span and Population columns and create a new Output column
ID Status Type Span State Population
A Yes 2 70% Ga 10000
Desired output
ID Status Type Span State Population Output
A Yes 2 70% Ga 10000 14000
dput
structure(list(ID = structure(1L, .Label = "A ", class = "factor"),
Status = structure(1L, .Label = "Yes", class = "factor"),
Type = 2L, Span = structure(1L, .Label = "70%", class = "factor"),
State = structure(1L, .Label = "Ga", class = "factor"), Population = 10000L), class = "data.frame",
row.names = c(NA,
-1L))
This is what I have tried
df %>%
mutate(Output = Type * Span * Population)