Skip to content

Instantly share code, notes, and snippets.

@krlmlr
Created January 23, 2013 10:08
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 krlmlr/4603945 to your computer and use it in GitHub Desktop.
Save krlmlr/4603945 to your computer and use it in GitHub Desktop.
dat <- read.table(text="VARIABLES DATE DATA
V1 1/03/2012 1000
V1 1/04/2012 1500
V1 1/12/2012 2600
V2 1/03/2012 900
V2 1/04/2012 1200
V2 1/12/2012 1000
V3 1/03/2012 200", header = TRUE)
library(reshape)
dat.m <- melt(dat, id.vars=c('VARIABLES', 'DATE'))
head(dat.m)
dat.c <- as.data.frame(cast(dat.m, VARIABLES~DATE+.))
head(dat.c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment