[R] Creating a new vector ( another problem)
    Dimitris Rizopoulos 
    dimitris.rizopoulos at med.kuleuven.be
       
    Mon Nov 20 16:40:04 CET 2006
    
    
  
try this:
y <- rnorm(1000)
#################
x <- rep(NA, 1000)
x[seq(5, 1000, 5)] <- colSums(matrix(y, 5))
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
----- Original Message ----- 
From: "Amir Safari" <amsa36060 at yahoo.com>
To: <R-help at stat.math.ethz.ch>
Sent: Monday, November 20, 2006 3:42 PM
Subject: [R] Creating a new vector ( another problem)
>
>
>
>
>
>     Dear R Users,
>
> Suppose we are  interested for generating a new vector ( x ) from a 
> current vector (y)  of length 1000 so that x includes the sum of 
> every 5 values in y  respectively from the first to the end of 
> length y. The same length of  y for x is desired, so that other 4 
> positions (indices) in x are filled  out with NA.
>
>  For generating such a new vector, I have no idea. I tried in some 
> ways  but all were wrong and therefore I do not want to confuse you.
>  How could such a purpose be coded?
>  Please help me with any idea. Thank you so much for help.
>  Amir Safari
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
> 
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
    
    
More information about the R-help
mailing list