Error unexpected '}] in "}" if else statement in R language : <p>I'm working on calculating Bond Value example in my Data Mining subject. I have problem with if else function. Here it is...</p>

<pre><code>P&lt;-1000 #original value - Menh gia trai phieu
T&lt;-20 #maturity - Thoi han trai phieu - semi
r&lt;-.06 #annual rate - Lai suat yeu cau
C&lt;-30 #present value of coupons - Lai dinh ki

BV &lt;- function(P,C,r,t,T){ #t = -th year
    #Find coupon Bon Value at time t mat T - Gia trai phieu
    tmat &lt;- T-t # How many years have you get your bonds for?
    acrued &lt;- C*2*t #already paid
    if(tmat != 0) { #include interim coupons
        i &lt;- seq(1,2*tmat) #BVsemi - seq()=for loop
        acrued + sum(C/(1+r/2)^i) + P/(1+r/2)^(2*tmat)
    }else{ 
        acrued + P/(1+r/2)^(2*tmat) 
    }
}
</code></pre>

<p>The error message is:
**</p>

<pre><code>&gt; }
Error: unexpected '}' in "}"
</code></pre>

<p>**</p>

<p>I've already read all the topics that related to my problem but none of them works well...
Please show me the light in this problem...</p>

<p>Thank you</p>

<p>Hoang Anh</p>
