jeromyanglim / learning_r

assorted notes to self while learning R
1 stars 0 forks source link

How to reshape from long to wide format in R? #21

Closed jeromyanglim closed 12 years ago

jeromyanglim commented 12 years ago

I often forget the details of all the options of the reshape command. I generally find the documentation a little bit confusing.

What's a good way to remember the options for reshape?

jeromyanglim commented 12 years ago

This UCLA tutorial is clear: http://www.ats.ucla.edu/stat/r/faq/reshape.htm The following adapts the UCLA code to a common example that I have:

w <- reshape(long_data, 
  timevar = "var_name",
  idvar = "id"
  direction = "wide")

Quick-R mentions the reshape package: http://www.statmethods.net/management/reshape.html