Load packages library(tidyverse) Starters Assume you have this data frame: x <- tribble( ~ colA, ~colB, ~colC, NA, 1, NA, 1, NA, 1 ) x #> # A tibble: 2 x 3 #> colA colB colC #> <dbl> <dbl> <dbl> #> 1 NA 1 NA #> 2 1 NA 1 But you want this one: y <- tribble( ~ colA, ~colB, ~colC, 1, 1, 1 ) y #> # A tibble: 1 x 3 #> colA colB colC #> <dbl> <dbl> <dbl> #> 1 1 1 1 That is, you’d like to collapse rows so that if there’s a NA in a column it is replaced by the value found in some other …