search for: lengthofdesiredresult

Displaying 1 result from an estimated 1 matches for "lengthofdesiredresult".

2012 Oct 22
4
creating a function using for if
Hi all, I'm trying to create a function where it can process a vector and also give a vector output accordingly #input: a,b anc c are constants, data is the vector #set the function fun<-function(a,b,c,data) { N=as.vector() for (i in min(data):max(data)){ if(i>c){ N<-(a*(i-c)^0.5)+(b*(i-c))} else {N<-0}} return(N) } #try dummy data=c(100,210,320,130,170,120,220,90,55,45)