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]]
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 <zowiti@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.Meys@Ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]]
Hi Zablone,
I have a few questions about your data, but think the reshape package is
ultimately what you want. So just look at it and see if you can get it
to do what you want.
Marsh Feldman
On Fri, 7 May 2010 01:21:09 -0700 , Zablone Owiti 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
>
--
Dr. Marshall Feldman, PhD
Director of Research and Academic Affairs
CUSR Logo
Center for Urban Studies and Research
The University of Rhode Island
email: marsh @ uri .edu (remove spaces)
Contact Information:
Kingston:
202 Hart House
Charles T. Schmidt Labor Research Center
The University of Rhode Island
36 Upper College Road
Kingston, RI 02881-0815
tel. (401) 874-5953:
fax: (401) 874-5511
Providence:
206E Shepard Building
URI Feinstein Providence Campus
80 Washington Street
Providence, RI 02903-1819
tel. (401) 277-5218
fax: (401) 277-5464
[[alternative HTML version deleted]]