Take a look at the package reshape, the functions ?melt and ?cast. Take a look at their website as well : http://had.co.nz/reshape/
Cheers Joris On Fri, May 7, 2010 at 10:21 AM, Zablone Owiti <zow...@ncst.go.ke> wrote: > Dear users, > > I have monthly station data (44) stations data for 45 years which I have > read in R using read.table. the data is in the format: > > Year Month Station1 Station2 ...................................... > Station 44 (i.e the column names in the 1st row), I also have the > latitude and longitude of the stations in a separate file in R (in the > format : Station LAT LON). > > I wish to rearrage this data to a format: > > Year Month Station Lat Lon > Variable > > 1960 01 station001 -22.992200 -43.232800 > 70 > > 1960 01 station002 -22.955600 -43.166700 > 69 > 1960 01 station003 -22.931700 -43.221700 7 > 89 > " > " > " > " > 2003 12 station043 -23.46473 -47.3836383 > 183 > 2003 12 station 044 -22.817500 -43.210000 7 > 179 > > How do I go about the task in R? > > Thanks---------------------------- > ZABLONE OWITI > GRADUATE STUDENT > College of Atmospheric Science > Nanjing University of Information, Science and Technology > Add: 219 Ning Liu Rd, Nanjing, Jiangsu, 21004, P.R. China > Tel: +86-25-58731402 > Fax: +86-25-58731456 > Mob. 15077895632 > Website: www.nuist.edu.cn > ==================================================== > > > [[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. > -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 joris.m...@ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[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.