I am trying to operate the following function on a vector (of t) but I get the following error:
rho.prime <- function(t, k=19000){
for (i in seq(1,length(t))){
if (abs(t[i]) <= k)
{ print(2*t[i])
return(2*t[i])
}
else
{
print(2*k*sign(t[i]))
return(2*k*sign(t[i]))
}
}
}
Here's the rho.prime function description:
The problem is that I am suspicious about the result:
> t=c(1,3,5,7,10)
> t
[1] 1 3 5 7 10
> rho.prime(t,k)
[1] 2
[1] 2
See Question&Answers more detail:os