[R] Writing a script for multiplying a progressively larger listsof items
Dimitris Rizopoulos
dimitris.rizopoulos at med.kuleuven.be
Thu Oct 19 14:02:08 CEST 2006
probably you're looking for ?cumprod(), e.g.,
cumprod(1:10)
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: "Fabio Sanchez" <Fabio.Sanchez at ki.se>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, October 19, 2006 1:49 PM
Subject: [R] Writing a script for multiplying a progressively larger
listsof 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
______________________________________________
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