We can use pmax
df$a <- do.call(pmax, c(df, na.rm = TRUE))
Or with coalesce
library(dplyr)
df %>%
   mutate(a = coalesce(a,b))
#  a    b
#1 1 <NA>
#2 2 <NA>
#3 3    3
#4 4    4
1
solved r simple way to merge 2 columns with not NA values [duplicate]