Skip to content

Instantly share code, notes, and snippets.

@tomatoiscoding
Created October 13, 2016 14:52
Show Gist options
  • Select an option

  • Save tomatoiscoding/f154369eb0636d3994b1102e1835cfd5 to your computer and use it in GitHub Desktop.

Select an option

Save tomatoiscoding/f154369eb0636d3994b1102e1835cfd5 to your computer and use it in GitHub Desktop.
vector intersect and return index
a <- c(1:10)
b <- c(1,3,5,11,12,13,14)
c <- intersect(a, b)
index.a <- match(c, a) # [1] 1 3 5
index.b <- match(c, b) # [1] 1 2 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment