FindID.R 548 B

123456789101112131415
  1. FindID <-
  2. function(ID, Data)
  3. {
  4. if(!is.object(ID) | !is.object(Data)) stop("ID and Data inputs must both be objects currently in your R workspace.")
  5. if(!all(names(ID) %in% names(Data))) stop("ID is not a subset of Data. All names of ID must match with rows in Data.")
  6. match.set <- Data[ ,match(names(ID), names(Data))]
  7. row.matches <- apply(match.set, 1, match, ID)
  8. ifelse(length(which(!is.na(apply(row.matches, 2, sum)))) == 0,
  9. return(cat("No matches found.\n")),
  10. return(which(!is.na(apply(row.matches, 2, sum)))))
  11. }