Skip to content

Instantly share code, notes, and snippets.

@wrgoldstein
Created September 20, 2013 15:39
Show Gist options
  • Save wrgoldstein/6639465 to your computer and use it in GitHub Desktop.
Save wrgoldstein/6639465 to your computer and use it in GitHub Desktop.
Efficient lookups in R
ids <- sample(c(9999,1021,4000),10, replace = TRUE)
lookup <- list(ix = c(9999,1021,4000), val = c('apple','pear','orange'))
print(lookup$val[match(ids,lookup$ix)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment