This is very confusing, I'm going to make a reprex so we can all work on the same code, Can you explain why this doesn't work for you?
xrt <- data.frame(
stringsAsFactors = FALSE,
XRT_code_small = c(77261L,77261L,77295L,77401L,
77401L,77401L,77401L,77401L,77401L,77401L),
Date_XRT = c("2015-07-30","2015-08-02",
"2015-07-23","2015-08-03","2015-08-05","2015-08-06",
"2015-08-09","2015-08-10","2015-08-11","2015-08-12")
)
code_names <- data.frame(
stringsAsFactors = FALSE,
Input_Code = c(77261L,77280L,77295L,77401L,
81781L,77751L,77753L,77900L,77902L,77903L),
Name_code = c("General_Office",
"General_Office","General_Office","General_Office","General_Office",
NA,NA,"WBRT_3D",NA,"Brain_3D")
)
library(dplyr)
xrt %>%
left_join(code_names, by = c("XRT_code_small" = "Input_Code"))
#> XRT_code_small Date_XRT Name_code
#> 1 77261 2015-07-30 General_Office
#> 2 77261 2015-08-02 General_Office
#> 3 77295 2015-07-23 General_Office
#> 4 77401 2015-08-03 General_Office
#> 5 77401 2015-08-05 General_Office
#> 6 77401 2015-08-06 General_Office
#> 7 77401 2015-08-09 General_Office
#> 8 77401 2015-08-10 General_Office
#> 9 77401 2015-08-11 General_Office
#> 10 77401 2015-08-12 General_Office
Created on 2020-02-05 by the reprex package (v0.3.0.9001)