Another way of achieving the same thing ... Using the mapply function to find min and max and then combining as desired. Code snippet below might help
df1 <- data.frame(in_fid = c(1, 2, 3, 4, 5, 6), near_fid = c(49, 63, 4, 3, 4, 171))
paste(mapply(min, df1$in_fid, df1$near_fid),
mapply(max, df1$in_fid, df1$near_fid), sep = " ")
Thanks
Arnab P