[R] data format setting

Clint Bowman clint at ecy.wa.gov
Fri Jun 13 18:38:25 CEST 2014


?sort,
?unique, and
subset come to mind.

Clint Bowman			INTERNET:	clint at ecy.wa.gov
Air Quality Modeler		INTERNET:	clint at math.utah.edu
Department of Ecology		VOICE:		(360) 407-6815
PO Box 47600			FAX:		(360) 407-7534
Olympia, WA 98504-7600

         USPS:           PO Box 47600, Olympia, WA 98504-7600
         Parcels:        300 Desmond Drive, Lacey, WA 98503-1274

On Fri, 13 Jun 2014, eliza botto wrote:

>
> Dear R family,
> I hope you all be doing great. I have a dataset of following format. The data file is of the following format.
>
>      st year month day discharge
> 1  A     2004     1   1  6.752828
> 2  A     2004     1   2  7.602053
> 3  A     2004     1   3  5.583619
> 4  A     2004     1   4  5.019562
> 5  A     2004     1   5  4.804489
> 6  A     2004     1   6  4.363541
> 7  A     2004     1   7  3.801333
> 8  A     2004     1   8  3.455991
> 9  A     2004     1   9  3.402634
> 10 A     2004     1  10  3.250693
> ......
> ......
> continue
> ......
> ......
>         st year month day discharge
> 20000    AY 1967    10   3      0.56
> 20001    AY 1967    10   4      0.56
> 20002    AY 1967    10   5      0.48
> 20003    AY 1967    10   6      0.56
> 20004    AY 1967    10   7      0.48
> 20005    AY 1967    10   8      0.40
> 20006    AY 1967    10   9      0.40
> 20007    AY 1967    10  10      0.56
> 20008    AY 1967    10  11      0.56
> 20009    AY 1967    10  12      0.65
> 20010    AY 1967    10  13      0.85
>
> you can see that there are five columns.
> The first column has the name of the station. I want to split the data w.r.t the names of the stations. Each station has data for certain years. for example "A" has data for years from 2004 to 2010 and for "AY" its from 1967 to 2000.similarly for other years there is data for different number of years.
> I want to make a list of matrices each containing the data for that station in the following format
> $A
> 2004	2005	2006	2007	2008	2009	2010
> ..
> ...
> ...
> ..
> ...
>
> $AY
>
> 1967	1968	....	2000
>
> each column should have 365 to 366 values depending on whether there is a leap year or not. obviously for non-leap years 366th row should be an NA.
> kindly help me on it.
> Thankyou very much in advance.
> Eliza
>
>
> 	[[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.
>



More information about the R-help mailing list