Skip to content

Instantly share code, notes, and snippets.

@thomas-kassel
Created February 11, 2017 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomas-kassel/04565d89dbefe767f1ea217223aa7dc6 to your computer and use it in GitHub Desktop.
Save thomas-kassel/04565d89dbefe767f1ea217223aa7dc6 to your computer and use it in GitHub Desktop.
Join NHANES tables by sequence ID
# Use Reshape2 to melt exercise data from "wide" to "long" format
# Perform left_join on sequence ID to combine exercise information with demographic
exerciseMins <- melt(data = exercise,id.vars = "seqID",
measure.vars = c('minsVigWork','minsModWork','minsWalkBike','minsVigRec','minsModRec'),
variable.name = 'exercise.type',value.name = 'mins.per.day') %>%
left_join(demographics,by='seqID')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment