I posted a similar question before and asked how to remove negative values from the code chunk below. FJCC kindly told me to put "filter(Result >= 0)" at the end of the code to get rid of them, and it worked well!
But now, instead of completely removing them, I want to set the negative values to zero. For example, if Result = -26, then I want my code to change that to Result = 0 for all negative observations for the column Result.
Final_df <- Initial_df %>% mutate(Result= case_when( `Type` == "A" ~ (Capability - Output)*(sum(Capability) - sum(Output)), `Type` == "B" | `Type` == "C" ~ (Forecast - Output), `Type` == "D" ~ Capability - Output))