Here's a tidyverse approach. Let's create a data frame with all the possibilities to make sure nothing gets missed.
library(tidyverse)
(z0 <- data_frame(A = c("y", "n", NA, NA, NA),
B = c("n", "n", "y", "n", NA),
C = c("n", "n", "n", "n", NA)))
#> # A tibble: 5 x 3
#> A B C
#> <chr> <chr> <chr>
#> 1 y n n
#> 2 n n n
#> 3 <NA> y n
#> 4 <NA> n n
#> 5 <NA> <NA> <NA>
Here's a safe approach using purrr::pmap_lgl that requires you to explicitly put in which variables you want to include to see where "y" might appear:
z0 %>%
mutate(new = pmap_lgl(., ~ any("y" == c(..1, ..2, ..3))))
Here's an approach using purrrlyr (a small package with some functions orphaned from purrr) which has the benefit of using ... to indicate all variables:
z0 %>%
purrrlyr::by_row(~ any("y" == ...), .collate = "rows", .to = "new")
Both give the same result:
#> # tibble [5 × 4]
#> A B C new
#> <chr> <chr> <chr> <lgl>
#> 1 y n n TRUE
#> 2 n n n FALSE
#> 3 <NA> y n TRUE
#> 4 <NA> n n NA
#> 5 <NA> <NA> <NA> NA
EDIT: The first solution (so-called "safe") doesn't work with factor variables (and possibly other classes) as discussed here. Seems like things get coerced to numeric, which is why this (very silly) code gives the desired result:
z0 %>%
mutate(new = pmap(.,
~ any(as.numeric(factor("y", levels = c("n", "y"))) ==
c(..1, ..2, ..3))))
newto equalTRUEif any columns A:C ==y?