Find data from one data frame from the data in another

1

I have a demand that I can not resolve. The problem is this: I have two tables and I need to find out if there are people in the same table, in case I need to see how much it wins in the second table and transport to the first one (in a new column), but it ends up picking up the values of form 'random', below is the code I made:

pensionista.especial <- read.xlsx("PensaoEspecial.xlsx")
pensionista.janeiro <- read.xlsx("PensaoMensal12.xlsx")

pensionista.janeiro <- transform(pensionista.janeiro, PensaoEsp = ifelse(ID.FUNCIONAL %in% pensionista.especial$ID.FUNCIONAL,
                                                                         1 ,0))

pensionista.janeiro <- transform(pensionista.janeiro, InstEsp = ifelse(ID_FUNCIONAL_INSTITUIDOR %in% pensionista.especial$ID_FUNCIONAL_INSTITUIDOR,
                                                                       1, 0))

basedetrabalho <- pensionista.janeiro[ , c(1,10,13,14,23,31,32,33,34,69, 78, 79)]

basedetrabalho <- transform(basedetrabalho, VB_ESP = ifelse(ID.FUNCIONAL %in% pensionista.especial$ID.FUNCIONAL, pensionista.especial$VL_BRUTO, 0))

I ask for help with this personal problem!

    
asked by anonymous 09.03.2017 / 14:22

1 answer

1

I already got the solution, it was through the merge function

merge(pensionista.janeiro, pensionista.especial[,c("ID.FUNCIONAL","VL_BRUTO")],
  by.x = "ID.FUNCIONAL", by.y = "ID.FUNCIONAL", all.x = TRUE)
    
09.03.2017 / 20:59