I have used the following code previously to add values of a row:
subset$EBIT <- rowSums(subset[c("rorresul", "resand", "rteinknc",
"rteinext", "rteinov")], na.rm = TRUE)
However, I would actually need to include the condition that "resand" should only be included if it is positive. The other values can be either positive or negative, it does not matter. I have used rowSums because otherwise my total ended up a missing value if one of the variables had a missing value in them.
If you need sample of data, here is some:
rorresul resand rteinknc rteinext rteinov
40 30 2 2 2
50 -40 5 5 5
30 0 1 1 1
Super appreciative of any help! Thanks!