This simple example will help you:
# example data
df = data.frame(id = c("A","B"),
date_ref = c("2013-01-26", "2013-01-08"),
date1 = c("2013-01-23", "2013-01-01"),
date2 = c("2013-01-20", "2013-01-07"),
stringsAsFactors = F)
df
# id date_ref date1 date2
# 1 A 2013-01-26 2013-01-23 2013-01-20
# 2 B 2013-01-08 2013-01-01 2013-01-07
library(dplyr)
library(lubridate)
library(tidyr)
# update date column to datetime variables
# (if needed)
df = df %>% mutate_at(vars(matches("date")), ymd)
df %>%
gather(type,date_new,-id,-date_ref) %>% # reshape dataset
group_by(id) %>% # for each id
filter(abs(difftime(date_ref, date_new)) == min(abs(difftime(date_ref, date_new)))) %>% # keep row with minimum distance between dates
ungroup() %>% # forget the grouping
select(-type) %>% # remove that variable
inner_join(df, by=c("id","date_ref")) # join back original dataset
# # A tibble: 2 x 5
# id date_ref date_new date1 date2
# <chr> <date> <date> <date> <date>
# 1 A 2013-01-26 2013-01-23 2013-01-23 2013-01-20
# 2 B 2013-01-08 2013-01-07 2013-01-01 2013-01-07
Not sure if you can have multiple dates with the same distance (same date multiple times of same number of days before/after your baseline date) and how you want to treat them.