I was looking for an R equivalent function to the vlookup
function in Excel and I came across lookup
in R, however when I try to use it I keep getting errors.
I have 2 data frames (myresday
and Assorted
). myresday
contains 2 columns: one with codes (column name is Res.Code
) and the other with corresponding days of the week (colname = ContDay
). Each of the codes represents a person and each person is matched with a day of the week they are supposed to be in work. Assorted
contains the record of when each person actually came in over the course of a year. It is a dataframe similar to myresday, however it is much bigger. I want to see if the codes in Assorted are matched with the correct days or if the days corresponding to each code is incorrect.
I was trying to use lookup
but kept coming across several errors. Here is my code:
Assorted$Cont_Day <- lookup(Assorted$VISIT_PROV_ID, myresday[, 1:2])
'the codes in myresday are in column 1, the days in column 2
R kept saying the function couldn't be found. I looked more into the function and someone suggested to use qdapTools library, so I put:
library('qdapTools')
before my code, and it said there is not qdapTools package.
Does anyone know how to do this or know of a better way to solve this?