I have two different dataframes:
df1 <- tibble(group = c(rep(1, 3), rep(2, 4), rep(1, 3)),
id = paste0("minutesPrompt", c(1, 2, 3, 1, 2, 3, 4, 1, 2, 3)),
number = c(rep("a", 3), rep("b", 4), rep("c", 3)),
minutesPrompt = c(1, 2, 4, 9, 18, 27, 36, 2, 3, 5),
timestamp = rep("xxxxxx", 10),
text1 = c("String", rep(NA_character_, 6), rep("String", 3)),
text2 = c(NA_character_, "String", rep(NA_character_, 5), "String", rep(NA_character_, 2)),
text3 = c(rep(NA_character_, 2), "String", rep(NA_character_, 7)))
df2 <- tibble(group = rep(2, 7),
id = paste0("minutesPrompt", c(1, 2, 3, 4, 1, 2, 3)),
number = c(rep("b", 4), rep("x", 3)),
minutesPrompt = NA,
timestamp = rep("xxxxxx", 7),
text1 = c("String", rep(NA_character_, 6)),
text2 = c(rep(NA_character_, 2), "String", rep(NA_character_, 4)),
text3 = c(NA_character_, "String", rep(NA_character_, 5)))
df1
(first picture) which is really big: This dataframe consists of a lot of variables, and includes the values of 3 different groups. It further has 7 rows for each participant expressed by id.df2
(second picture) contrarily consists only of the variables shown for one group only. The difference between the datasets is also that df1 has some missing values (yellow). The strings that should be transferred into those empty cells are included in df2 (orange).
My plan is to conduct a full join so that I can replace the missing information in df1 on "timestamp", "text1", "text2", until "text7" by the provided values of df2. I have tried this:
full_join(df1, df2) %>%
group_by("id", "number")
However this does not replace my missing cells (highlighted in yellow) by the strings in df2.