Skip to content

Instantly share code, notes, and snippets.

@Ironholds
Created August 15, 2013 15:05
Show Gist options
  • Select an option

  • Save Ironholds/6241567 to your computer and use it in GitHub Desktop.

Select an option

Save Ironholds/6241567 to your computer and use it in GitHub Desktop.
Dinky
#Dataframes (of strings. Glorious strings)
foo <- data.frame(c("foo","qux","baz","quux"),c("baz","bar","foo","corge"))
bar <- data.frame(c("foo","bar","baz"),c("baz","bar","foo"))
#Retrieve the subset of foo that matches entries in bar.
@Protonk
Copy link
Copy Markdown

Protonk commented Aug 16, 2013

See here for a very kludgy solution. You're facing a general problem here, not an R problem (meaning doing multiple sub-element matching). So there will be a few solutions.

@Protonk
Copy link
Copy Markdown

Protonk commented Aug 16, 2013

Here is a smarter solution, but you'll need to do a bit of work to recover them in a conformable format. That part was boring so I didn't do it.

@Ironholds
Copy link
Copy Markdown
Author

Yeah, that second one looks a lot like one of my proposed solutions (although I used ddply)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment