I am trying to write a function based on this formula.
(x − x0)^ r+ = { (x-x0)^r if x>x0
0 otherwise
what I understood from above is;
y= (x-x0)^r unless x<= x0
so for each element of, identify if greater and x0 if so return y that equals the formula.
tp <- function(x,x0,r) {
y<-list()
if (x[i] >x0) {
for (i in seq_along(x)) {
y<- append((x[i]-x0)^r)
} else {
y <- append(0)
}
}
return(y)
}
I have tried doing this but I couldn't make it work. Could anyone advise me if I understood the formula right and if so what is the correct way to coed it.