In C++ the ternary operator enables shorthand conditional assignment of variable values:
x = y > 2 ? y : 2;
In R, the closest operation of which I am aware is the following:
ifelse(y > 2, x <- y, x <- 2)
It just feels clumsy and looks OO awkward to type x
twice on the same line, especially when doing this dozens of times. Is there a cleaner method for conditional assignment in R?