I came from the world of Python. I want to only get the positive number and set non-positive number to be zero. In Python:
>> a = [1,2,3,-1,-2, 0,1,-9]
>> [elem if elem>0 else 0 for elem in a]
[1, 2, 3, 4, 0, 0, 0, 1, 0]
Say I have a vector in R, how can I get the same result.
a <- c(1,2,3,-1,-2, 0,1,-9)