Hi BJ, Suppose that your data set is called 'Data1', please copy and paste the output created by typing:
dput(Data1[1:15, ]) and post that to the list ***in plain text*** (or upload a text file on some file hosting service). The email you sent is nearly impossible to parse because this is a plain text list (as noted in the posting guide) and your html formatting is utterly lost. Josh On Sun, Aug 7, 2011 at 6:19 PM, B Jessop <deel...@hotmail.com> wrote: > > > Dear help list: I am trying to reshape a data frame from long to wide format > and with a reduced variable list using reshape2. The original data frame > format is: Site Obs_no LengthSite 1 Obs 1 10Site 1 Obs 2 > 13Site 1 Obs 3 14.........Site 2 Obs 1 5Site 2 Obs 2 > 7Site 2 Obs 3 9 Site and Obs_no are factors and Length is a numeric > variable. There are 15 cases in each Site group. The objective is to > rearrange to: Site 1 Site 210 513 714 9 ........ I > have tried a variety of approaches, none of which worked. The following code > does not work but suggests the task might be possible, perhaps in 2 steps. > Df2 <- dcast (Data1, Length ~ Site, value_var = "Length") Its output is: > Length Site 1 Site 210 10 NA13 13 NA14 > 14 NA.......5 NA 57 NA 79 > NA 9 One easy solution is to reshape in Excel and import a new > dataframe fo! > r use but I would like to do it in R. Any suggestions would be much > appreciated. Regards,BJ > [[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. > -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, ATS Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/ ______________________________________________ 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.