multi<-function(x0) {
    result<-rep(0,length(x0))
    for ( i in 1:length(x0)) result[i]<-prod(x0[1:i])
    result  
}
 
Justin BEM
Elève Ingénieur Statisticien Economiste
BP 294 Yaoundé.
Tél (00237)9597295.



----- Message d'origine ----
De : Fabio Sanchez <[EMAIL PROTECTED]>
À : [email protected]
Envoyé le : Jeudi, 19 Octobre 2006, 12h49mn 12s
Objet : [R] Writing a script for multiplying a progressively larger lists of 
items


Hi, I would like to get guidance as to how to write code in R that can 
deal with the following situation:

v1 is a vector containing a sequence of numbers (Ex. 1:10)
I want to store the sequence of numbers resulting from multiplying the 
first and the second element in the vector, then the product of the 
1st, 2nd and 3rd, then 1st,2nd,3rd and 4th and so forth until all the 
elements in the vector are multiplied.

Many thanks,

Fabio


Fabio Sánchez, MD, MSc, PhD
Molecular Dermatology
Department of Medicine
Karolinska Institute
SE-17176 Karolinska University Hospital
Tel: +46 8 51772158

______________________________________________
[email protected] 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.


        

        
                
___________________________________________________________________________ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 


        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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.

Reply via email to