2022-03-25

Values of a vector to remain equal to another vector based on conditions

I'm using this dataset.

I want to create a variable named neg_gw_shock such that

neg_gw_shock = (-gw_level_dev) if gw_level_dev < 0 
neg_gw_shock =  NA if gw_level_dev >= 0

How can I do that?



No comments:

Post a Comment