I want to add Column A and X based on the conditions that if the result is greater than zero, use the summation result otherwise make it zero. Here is my code so far
library(tidyverse)
library(set.seed(1500)
FakeData <- data.frame(A = runif(20,-5,20), X = runif(20,0,22))
FakeData$sum <- if (sum(FakeData$A+FakeData$X) < 0){
0
} else {
sum(FakeData$A+FakeData$X
}
Aucun commentaire:
Enregistrer un commentaire