if statement - Loops inside functions in r -
i'm having problem in setting loops. want create function have several arguments , 1 of argument vector, , each value in vector must truncate infinite series , give me sum.
my code this:
zt<-function(t,p,e){for (i in t){v=0;j=0 repeat{v=v0;v=v+(i^j/factorial(j)^p) if (v-v0 < e) break else j<-j+1}} return(v)} t=c(0.2,0.4,0.6,0.8);zt(t,0.5,0.00005)
it returns lastly value in t
, yet i
want each value in t
.
r if-statement
No comments:
Post a Comment