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)
try=fun(10000,0.2,150,data=data)

what I get is:
Error in as.vector() : argument "x" is missing, with no default

Please help, thanks!

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to