Displaying 1 result from an estimated 1 matches for "tp1690812p1690861".
Did you mean:
tp1690812p1690812
2010 Mar 25
1
how to deal with vector[0]?
Hi,
I have a vector with 4 elements, e.g., tau_i=c(100,200,300,400), but
potentially tau_i[0]=0. In a "for" loop,
tau_i=c(100,200,300,400)
m=4
tau_i[0]=0 # <------- ?
P_i=1
for(i in 2:m)
{
P_i = P_i*(tau_i[i-1]-tau_i[i-2])
}
Error in P_i = P_i * (tau_i[k - 1] - tau_i[k - 2]):
replacement has length zero
Unfortunately, I can add this potential element into