Hi @srini,
It is a little hard to tell what you're going for without a reprex, but using a for-loop
over rows in a data frame is usually not a good use pattern in R. I think the dplyr
code below reproduces your intent, is easier to read, and should run substantially faster because of the vectorization of R functions.
df1 %>%
mutate(row_id = row_number()) %>%
group_by(row_id) %>%
mutate(out = sum(Skill == df2$Skill &
(job == df2$jb | job + 1 == df2$jb) &
conditions == "L" &
Work_Location == df2$Base.country &
Availability.date > lessmonth1 &
greatmonth1 >= Availability.date)) %>%
ungroup()