Translating Stata to R yields different results
None of bod, do or lnfcoli are missing (NA), so your logic returns FALSE and returns NA_integer_ (false= in the if_else). Stata treats . or missing values as positive infinity, so that check is actually looking for not missing.
So the equivalent in R/dplyr is probably:
data %>%
    mutate(
        tau = if_else(
        (temp2 > temp3) & (!(is.na(bod) | is.na(do) | is.na(lnfcoli))),
        year-temp2,
        NA_integer_
        )
    )

#  year temp2 temp3 bod  do lnfcoli tau
#1 1986  1995  1986 3.2 7.2     2.1  -9


I am trying to translate a Stata code from a paper into R.
The Stata code looks like this:
g tau = year - temp2 if temp2 > temp3 & (bod<. | do<. | lnfcoli<.)

My R translation looks like this:
data <- data %>%
  mutate(tau = if_else((temp2 > temp3) & 
                         (is.na(bod) | is.na(do) | is.na(lnfcoli)), 
                       year - temp2,
                       NA_integer_))

The problem is that when I run each code I get different results.
This is the result I get when I run the code in Stata:
1   Year |  temp2  |  temp3 | bod | do  | lnfcoli | tau |
2   1986 |  1995   |  1986  | 3.2 | 7.2 | 2.1.    |  -9 |

This is the result I get when I run the code in R:
1   Year |  temp2  |  temp3 | bod | do  | lnfcoli | tau |
2   1986 |  1995   |  1986  | 3.2 | 7.2 | 2.1.    |  NA |

Do you know what might be wrong with my R code or what should I modify to get the same output?
