You can set negatives to 0 using the conditional assignment. For instance: var <- ifelse(var < 0, 0, var).