List lookup R with 2 df

Hi Rcommunity

got another problem, have 2 df:

sample id:
structure(list(ID = c(595119208, 595174634, 210018628, 355597680
)), class = "data.frame", row.names = c(NA, -4L))

i want to see if the sample ID (from the first df exist in bogaa df, and if it does it should return a 1 in the "dboga$bogarule" else 0. and it should return the name of the main lead in "boga$meanlead" elso na.

thx!

Hi @jak123 ,

Is it what you're looking for?

sample_id %>% mutate(
  bogarule = ifelse(ID %in% bogaa$ID, 1, 0), 
  meanLead = ifelse(ID %in% bogaa$ID, bogaa$meanLead, NA))

thx! alot xvalda !!!!!

Fixed and thanks alot, i will return later :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.