I am trying to write R code that
- creates a new variable
- populates that variable only if METRO=0
- the values that are populated are a random assignment of "1" and "2" values.
I tried something like this but it did not work:
iPUMS_2016 <- mutate (iPUMS_2016, metrounk = ifelse(METRO==0,mutate(rand_int=sample.int(n())) ))