Hi All, I have a large dataset I need to re-structure. It looks something like this: YearAreaQBinFD20001150200011101200011152320001120122000112512000215120002110 6200021151120002120132000212532000125020001210120001215232000122012200012251 20002251200022103200022151220002220132000222532001…2011 And I need to create different vectors (Bin, FD) summing by year and/or by area; For example, I need a new dataset: Bin, FD[Year=2000,Area=1], FD[Year=2000,Area=2], FD[Year=2000], FD[Year=2001,Area=1], etc. Any help really appreciated!! NG [[alternative HTML version deleted]]
Nicolas: Start by Helping yourself. Read the docs -- e.g. the "Introduction to R tutorial that ships with R, or one or more of the many that you can find on the Web. -- Bert On Thu, Apr 4, 2013 at 6:17 AM, Nicolas L. Gutierrez <nicolasg at uw.edu> wrote:> Hi All, > > I have a large dataset I need to re-structure. It looks something like this: > > > YearAreaQBinFD20001150200011101200011152320001120122000112512000215120002110 > 6200021151120002120132000212532000125020001210120001215232000122012200012251 > 20002251200022103200022151220002220132000222532001?2011 > > And I need to create different vectors (Bin, FD) summing by year and/or by > area; For example, I need a new dataset: > Bin, FD[Year=2000,Area=1], FD[Year=2000,Area=2], FD[Year=2000], > FD[Year=2001,Area=1], etc. > Any help really appreciated!! > NG > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help at 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. >-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
Hi> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Nicolas L. Gutierrez > Sent: Thursday, April 04, 2013 3:17 PM > To: r-help at r-project.org > Subject: [R] summing vectors/matrices > > Hi All, > > I have a large dataset I need to re-structure. It looks something like > this: > > > YearAreaQBinFD200011502000111012000111523200011201220001125120002151200 > 02110 > 62000211511200021201320002125320001250200012101200012152320001220122000 > 12251 > 20002251200022103200022151220002220132000222532001...2011I cannot believe that your dataset does not have any delimiters. If it is really the case read.fwf can be a way to go. If your data are in dataframe then you probably can use aggregate But without knowing data structure and desired result it is hard to tell anything definite. Regards Petr> > And I need to create different vectors (Bin, FD) summing by year > and/or by area; For example, I need a new dataset: > Bin, FD[Year=2000,Area=1], FD[Year=2000,Area=2], FD[Year=2000], > FD[Year=2001,Area=1], etc. > Any help really appreciated!! > NG > > [[alternative HTML version deleted]]