J'ai deux dataframes de cette forme:
Code : Tout sélectionner
df1<-structure(list(x1 = c("A", "B", "C", "D", "E", "F", "G", "H",
"I", "J"), x2 = c("book", "pen", "textbook", "pencil_case", "textbook",
"pencil_case", "pen", "textbook", "pencil_case", "textbook"),
x3 = c("M1", "F2", "M3", "M4", "M5", "F6", "F7", "M8", "M9",
"M10")), class = "data.frame", row.names = c(NA, -10L))
Code : Tout sélectionner
df2<-structure(list(id = 1:3, value = c(10, 20, 30)),
class = "data.frame", row.names = c(NA, -3L))
Je souhaiterais obtenir un dataframe de ce type
Code : Tout sélectionner
df3<-structure(list(x1 = c("A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "A",
"B", "C", "D", "E", "F", "G", "H", "I", "J"),
x2 = c("book", "pen", "textbook", "pencil_case", "textbook", "pencil_case",
"pen", "textbook", "pencil_case", "textbook", "book", "pen",
"textbook", "pencil_case", "textbook", "pencil_case", "pen",
"textbook", "pencil_case", "textbook", "book", "pen", "textbook",
"pencil_case", "textbook", "pencil_case", "pen", "textbook",
"pencil_case", "textbook"), x3 = c("M1", "F2", "M3", "M4", "M5",
"F6", "F7", "M8", "M9", "M10", "M1", "F2", "M3", "M4", "M5",
"F6", "F7", "M8", "M9", "M10", "M1", "F2", "M3", "M4", "M5",
"F6", "F7", "M8", "M9", "M10"), value = c(10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30,
30, 30, 30, 30, 30, 30, 30, 30, 30)),
class = "data.frame", row.names = c(NA,-30L))
Je voudrais affecter chaque valeur de ma variable "value" à chaque observation de mon dataframe d1. Je n'ai pas d'identifiants
communs aux deux dataframes pour procéder à une jointure.
Je sollicite votre aide.
Cordialement
Fabrice Yaméogo