[R] How to convert a single column into many rows

Kenn Konstabel lebatsnok at gmail.com
Wed Mar 23 12:25:27 CET 2011


On Wed, Mar 23, 2011 at 11:13 AM, Zablone Owiti <zowiti at ncst.go.ke> wrote:
> Dear users,
>
> I wish to convert a column of data  containing  pentad (5day mean data)
> from 1962 - 2000 into rows with each row having 73 values (ie. 73 pentads
> per year).
>
>
>
>  1962  pent1  pent2  ............pent73
>
> .
> .
> .
> .
>
> 2000 pent1 pent2 ..............pent73
>
>
> What commands should I use to achieve this?
>
> Thanks
>

my.pentads<-paste(rep(1962:2000, each=73), 1:73)  # generate sample data
 matrix(my.pentads, ncol=73, byrow=TRUE)


>
>
> ----------------------------
>
>  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
>
> ====================================================
>
> DO NOT PRINT THIS E-MAIL UNLESS NECESSARY. THE ENVIRONMENT CONCERNS US
> ALL.
>
> ______________________________________________
> 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