Dear Guys,

I do converting codes from Fortran into R and got stuck in solving LOOPING
procedure with R. In FORTRAN, it is (DO and END DO) for looping in the net.
In R, it is (FOR with {   }).

I believe there is something wrong with my coding in R, do hope that you can
help me solving following problems.

It seems easy, but results are not the same.

***************************************************************************
WITH R

theta<-c(0.08,0.06,0.09,0)
for (i in 1:4){
for (j in 1:4){
a<-1.0
for (k in i:(j-1)){
a<-a*theta[k]
}
print(a)
}
--------------------------------------------------------------------------------------
HERE GOES the results
-------------------------
numeric(0)
[1] 0.08
[1] 0.0048
[1] 0.000432
numeric(0)
[1] 0.0048
[1] 0.06
[1] 0.0054
numeric(0)
[1] 0.000432
[1] 0.0054
[1] 0.09
numeric(0)
[1] 0
[1] 0
[1] 0
*********************************************************************************
IN FORTRAN, the results is totally different.

program calculating_a
implicit none
integer i, j, k
double precision a, theta(4)
theta(1)=0.06; theta(2)=0.08; theta(3)=0.09; theta(4)=0
do i=1, 4
do j=1, 4
a=1
do k=i,j-1
a=a*theta(k)
end do

print*, a

end do
end do
end

Here goes the results with FOTRAN

-------------------------------------------------------------------------------------
1
0.06
4.79E-003
4.31E-004
1
1
0.08
7.2E-0.03
1
1
1
0.09
1
1
1
1
-----------------------------------------------------------------------------



Thank you!



Nam

	[[alternative HTML version deleted]]

