maxbre wrote on 09/09/2011 06:28:15 AM: > > This is my reproducible example: > > example<-structure(list(SENSOR = structure(1:6, .Label = c("A", "B", "C", > "D", "E", "F"), class = "factor"), VALUE = c(270, 292.5, 0, 45, > 247.5, 315), DATE = structure(1:6, .Label = c(" 01/01/2010 1", > " 01/01/2010 2", " 01/01/2010 3", " 01/01/2010 4", " 01/01/2010 5", > " 01/01/2010 6"), class = "factor")), .Names = c("SENSOR", "VALUE", > "DATE"), class = "data.frame", row.names = c("1", "2", "3", "4", > "5", "6")) > > I need to resahpe "example" in a wide format so that ?SENSOR? appear as > columns and ?DATE? as rows with corresponding ?VALUE? as value;
It's not clear to me what the wide format of your example would look like. You start with this: SENSOR VALUE DATE 1 A 270.0 01/01/2010 1 2 B 292.5 01/01/2010 2 3 C 0.0 01/01/2010 3 4 D 45.0 01/01/2010 4 5 E 247.5 01/01/2010 5 6 F 315.0 01/01/2010 6 And you want to change it to ... something like this? DATE A B C D E F 01/01/2010 1 270 NA NA NA NA NA 01/01/2010 2 NA 292.5 NA NA NA NA 01/01/2010 3 NA NA 0 NA NA NA 01/01/2010 4 NA NA NA 45 NA NA 01/01/2010 5 NA NA NA NA 247.5 NA 01/01/2010 6 NA NA NA NA NA 315 Jean > > I thought it was very simple so that I?ve been trying this: > > dcast(example,DATE~SENSOR) > > But I've got this message: > > Using DATE as value column. Use the value argument to cast to override this > choice > Errore in `[.data.frame`(data, , variables, drop = FALSE) : > undefined columns selected > > and even if by using the value argument sorted out any good result? > > sorry for the very trivial question, I've been looking at documentation and > forums anywhere but I was not successful at all and now I?m somehow in the > right middle of nowhere? > > any help or hint for this? > > thank you > > max > [[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.