I want to use for (i in 1:time) but I want the increments to be monthly. For example, if I'm adding interest to a virtual bank account monthly, for a total of 'time' in years which the user has entered. Is there a simple way of doing this please? I'm not familiar with many R functions yet. -- View this message in context: http://r.789695.n4.nabble.com/for-in-steps-tp3946248p3946248.html Sent from the R help mailing list archive at Nabble.com.
'for' in steps
4 messages · RhoR, Marc Girondot, David Winsemius
Le 28/10/11 00:29, RhoR a ?crit :
I want to use for (i in 1:time) but I want the increments to be monthly. For example, if I'm adding interest to a virtual bank account monthly, for a total of 'time' in years which the user has entered.
If I understand well the problem:
for (i in 1:time) {
for (j in 1:12) {
# add the monthly interests
# total number of months=(i-1)*12+j
}
}
or simpler:
for (i in 1:(time*12)) {
}
Sincerely
On Oct 27, 2011, at 6:29 PM, RhoR wrote:
I want to use for (i in 1:time)
That is insufficient to tell what sort of date or date-time object you intend. You may want to look at: ?ISOdate ?DateTimeClasses > ISOdate(2011, 1:12, 1) [1] "2011-01-01 12:00:00 GMT" "2011-02-01 12:00:00 GMT" "2011-03-01 12:00:00 GMT" [4] "2011-04-01 12:00:00 GMT" "2011-05-01 12:00:00 GMT" "2011-06-01 12:00:00 GMT" [7] "2011-07-01 12:00:00 GMT" "2011-08-01 12:00:00 GMT" "2011-09-01 12:00:00 GMT" [10] "2011-10-01 12:00:00 GMT" "2011-11-01 12:00:00 GMT" "2011-12-01 12:00:00 GMT"
but I want the increments to be monthly. For example, if I'm adding interest to a virtual bank account monthly, for a total of 'time' in years which the user has entered. Is there a simple way of doing this please? I'm not familiar with many R functions yet. -- View this message in context: http://r.789695.n4.nabble.com/for-in-steps-tp3946248p3946248.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
David Winsemius, MD West Hartford, CT
Thank you Marc and David for your suggestions. I think Marc's is going to work nicely for what I need but I'll also try David's. Many thanks both Fiona -- View this message in context: http://r.789695.n4.nabble.com/for-in-steps-tp3946248p3947950.html Sent from the R help mailing list archive at Nabble.com.