[R] matrix transformation into 3 columns
Dimitrios Rizopoulos
Dimitris.Rizopoulos at med.kuleuven.be
Thu May 18 19:03:34 CEST 2006
probably ?reshape() could be used in this case; I hope it helps.
Best,
Dimitris
--
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
Quoting Rado Bonk <rado.bonk at jrc.it>:
> Dear R-users,
>
> I have matrix (mprecip) with headers:
>
> > dim(mprecip)
> [1] 6268 170
>
> > mprecip
> date GilzeRijen Eindhoven Volkel ZuidLimburg Arcen
> Ubachsberg
> 1 01/01/1978 NA 0.0 NA 0.1 NA
> NA
> 2 01/02/1978 NA 0.0 NA 0.0 NA
> NA
> 3 01/03/1978 NA 1.9 NA 0.7 NA
> NA
> 4 01/04/1978 NA 3.5 NA 6.9 NA
> 6.0
> 5 01/05/1978 NA 1.6 NA 1.8 NA
> 1.3
> 6 01/06/1978 NA 0.0 NA 0.0 NA
> NA
> 7 01/07/1978 NA 0.0 NA 0.0 NA
> NA
> 8 01/08/1978 NA 0.0 NA 0.0 NA
> NA
>
> Columns are: DATE and PRECIP values for each station listed in the
> header.
>
> I would like to transform the matrix into three columns (database
> like)
> to be able to load the data in the database:
>
> STATION_NAME1 DATE PRECIP
> STATION_NAME1 DATE PRECIP
> STATION_NAME1 DATE PRECIP
> STATION_NAME1 DATE PRECIP
> .
> .
> .
> .
> STATION_NAME2 DATE PRECIP
> STATION_NAME1 DATE PRECIP.
> .
> .
> .
> STATION_NAME3 DATE PRECIP
>
>
>
>
> --
> Dr. Radoslav Bonk
> European Commission - DG Joint Research Centre (JRC)
> Institute of Environment and Sustainability (IES)
> LM Unit - Natural Hazards
> Via E. Fermi, TP 261, 210 20 Ispra (VA), ITALY
> tel: 0039 0332 78 6013
> fax: 0039 0332 78 6653
> http://natural-hazards.jrc.it/floods
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
More information about the R-help
mailing list