I'm having some difficulty in R and I don't know how I can do this. I have an excel spreadsheet and I'm developing a script in R, and I'm stuck in a part where I need to do something like a VLOOKUP, but in R, how could I do that?
Objective: I have two dataframes, one called "tb_consolidada" and "tbGEMOR", and both have a column with this name "R2500_PPNCOD", I need you to create a new column in the df "tb_consolidada" and make a comparison between the two columns, and what he finds equal he returns, if not returns empty.
Obstacle: How could it be done, would using Lef_join be ideal? I'll leave a script of how I tried it.
# Grouping tbs
tb_consolidada <- bind_rows(goals1, goals2)
View(tb_consolidated)
# Remove column R1900_CTCCHVCONTA
tb_consolidada$R1900_CTCCHVCONTA <- NULL
#Remove duplicate lines from column PPNCOD
consolidated_tb <- consolidated_tb[!duplicated(consolidated_tb$R2500_PPNCOD), ]
# Sort column from largest to largest (descending order)
tb_consolidada <- tb_consolidada[order(tb_consolidada$R1900_CCSDATLIQ, decreasing = TRUE), ]
#Create tbGEMOR (Last Consolidated tb containing all data)
tbGEMOR<- read.xlsx("C:/Users/AlaxAtaide/Desktop/Metas/Redirecionamento_05122022_26122022v3_enviar.xlsx", sheet = 1)
View(tbGEMOR)
#Creating check column (does it exist?)
VLOOKUP <- left_join(tb_consolidada, tbGEMOR, by='R2500_PPNCOD')