Hi guys. Granted that this is not generally a row-wise operation, I still think it would be good to bring to your attention. The issue came about on Stack Overflow, where an error was discovered in the resulting data frame.
http://stackoverflow.com/questions/33090745/dplyrrowwise-mutate-and-na-error
A minimal example is as follows
data.frame(k = c(-1, 1, 1)) %>%
rowwise() %>%
mutate(l = ifelse(k > 0, 1, NA))
Source: local data frame [3 x 2]
Groups: <by row>
k l
(dbl) (dbl)
1 -1 NA
2 1 1
3 1 NA
We believe that row 3, column l should be 1, not NA as shown.
If you run the following code a few separate times, you will find that the incident above only occurs intermittently.
data.frame(k = rnorm(10)) %>%
rowwise() %>%
mutate(l = ifelse(k > 0, 1L, NA_integer_))