What am I doing wrong ? Using the method you proposed on SLIGHTLY different data.
> head(x) Region YearMon kg AP 200701 290,311 AP 200702 322,671 AP 200703 216,600 AP 200704 450,711 AP 200705 245,215 AP 200706 212,492 j <-dcast(x,YearMon~Region,value.var='kg') sing kg as value column: use value_var to override. rror in names(data) <- array_names(res$labels[[2]]) : 'names' attribute [4] must be the same length as the vector [1] j <-dcast(x,YearMon~Region,value_var='kg') rror in names(data) <- array_names(res$labels[[2]]) : 'names' attribute [4] must be the same length as the vector [1] -----Original Message----- From: arun kirshna [via R] <ml-node+s789695n4649889...@n4.nabble.com> To: eric <ericst...@aol.com> Sent: Sat, Nov 17, 2012 5:23 pm Subject: Re: Reshaping a dataframe HI, Try this: dat1<-read.table(text=" State Date lbs TX 200701 400 TX 200702 650 TX 200703 950 TX 200704 1000 FL 200701 200 FL 200702 300 FL 200703 500 FL 200704 333 NJ 200701 409 NJ 200702 308 NJ 200703 300 NJ 200704 800 ",sep="",header=TRUE,stringsAsFactors=FALSE) library(reshape2) dcast(dat1,Date~State,value.var="lbs") # Date FL NJ TX #1 200701 200 409 400 #2 200702 300 308 650 #3 200703 500 300 950 #4 200704 333 800 1000 A.K. If you reply to this email, your message will be added to the discussion below: http://r.789695.n4.nabble.com/Reshaping-a-dataframe-tp4649874p4649889.html This email was sent by arun kirshna (via Nabble) To receive all replies by email, subscribe to this discussion -- View this message in context: http://r.789695.n4.nabble.com/Reshaping-a-dataframe-tp4649874p4649890.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.