[R] 'for' in steps

Marc Girondot marc_grt at yahoo.fr
Fri Oct 28 06:11:27 CEST 2011


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



More information about the R-help mailing list