Skip to content

Instantly share code, notes, and snippets.

@trcook
Created April 3, 2013 13:58
Show Gist options
  • Select an option

  • Save trcook/5301414 to your computer and use it in GitHub Desktop.

Select an option

Save trcook/5301414 to your computer and use it in GitHub Desktop.
expand factor into dichotomous variables
require(reshape2)
dcast(pds2,codeyear~lparty,length,value_var="codeyear")->tmp
# the codeyear variable is the row identifier. use this to remerge back into the dataset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment