3
I have two tables: dados
and dados_aux
. I need to add to the table dados
the column REGIÃO
, present in the table dados_aux
.
However, I have to use two keys to make the Join: CIDADE
and UF
. Otherwise, the information will be incorrect.
It is possible to make this Join with two keys using the merge()
? If yes, how would it be?
Table dados
:
structure(list(CIDADE = structure(c(4L, 5L, 1L, 2L, 3L), .Label = c("BOA VISTA",
"MANAUS", "RECIFE", "RIO DE JANEIRO", "SAO PAULO"), class = "factor"),
UF = structure(c(3L, 5L, 4L, 1L, 2L), .Label = c("AM", "PE",
"RJ", "RR", "SP"), class = "factor")), .Names = c("CIDADE",
"UF"), row.names = c(NA, -5L), class = "data.frame")
Table dados_aux
:
structure(list(CIDADE = structure(c(4L, 5L, 1L, 1L, 2L, 3L, 3L
), .Label = c("BOA VISTA", "MANAUS", "RECIFE", "RIO DE JANEIRO",
"SAO PAULO"), class = "factor"), UF = structure(c(4L, 7L, 5L,
2L, 1L, 6L, 3L), .Label = c("AM", "MG", "PE", "RJ", "RR", "SC",
"SP"), class = "factor"), REGIAO = structure(c(3L, 3L, 2L, 3L,
2L, 4L, 1L), .Label = c("NORDESTE", "NORTE", "SUDESTE", "SUL"
), class = "factor")), .Names = c("CIDADE", "UF", "REGIAO"), row.names = c(NA,
-7L), class = "data.frame")