library(tidyverse)
df <- structure(list(`A` = c("Home", NA, "Foreign", NA, "Central", NA),
`B` = c("Good", "Very Good", "Bad", "Fair", "Very Bad", "Worst")),
row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))
df %>%
mutate(AA = ifelse(B %in% c("Good", "Very Good"), "Home", ifelse(B %in% c("Bad", "Fair"), "Foreign", ifelse(B %in% c("Very Bad", "Worst"), "Central", NA))),
A = ifelse(is.na(A), AA, A))
#> # A tibble: 6 x 3
#> A B AA
#> <chr> <chr> <chr>
#> 1 Home Good Home
#> 2 Home Very Good Home
#> 3 Foreign Bad Foreign
#> 4 Foreign Fair Foreign
#> 5 Central Very Bad Central
#> 6 Central Worst Central