I'm not sure if I understand your request correctly, so please let me know if this isn't what you're looking for.
You can use target_cc to join with df, but it needs to be the same length as df.
Using dplyr
:
library(dplyr)
country <- rep(c("AT","BE","CY","DE","EE"), 10)
value <- seq(1, 50)
df <- data.frame(country, value)
target <- data.frame(
country = rep(c("DE","CY","BE","AT","EE"), times = 5)
)
df2 <- df %>%
right_join(target, by = "country") %>%
distinct()
head(df2)
#> country value
#> 1 DE 4
#> 2 DE 9
#> 3 DE 14
#> 4 DE 19
#> 5 DE 24
#> 6 DE 29
tail(df2)
#> country value
#> 45 EE 25
#> 46 EE 30
#> 47 EE 35
#> 48 EE 40
#> 49 EE 45
#> 50 EE 50
Created on 2020-02-07 by the reprex package (v0.3.0)
Since this will produce the cross-product, use distinct
to keep only the unique rows.