The set up code. If it runs fine you should get a list of 5 vectors, with each vector having 800 numbers.
h5=rep(0,800);h6=h5;h7=h5;h8=h5;h9=h5
list_knot<- list(h5,h6,h7,h8,h9)
list_length <- length(list_knot) # 5
x=seq(from=-400,to=400,length.out=800)
vec1 <- list(c(1, 2, 3, 4, 5)) # as per your requirement
list_knot <- lapply(vec1[[1]], function(v, x) x - v^3, x = 1:800)
I was wondering how I could make all of the values within list_knot that are < 0 = 0 within that function or another function?
>Solution :
I think pmax(0, .), should work, i.e.
list_knot <- lapply(vec1[[1]], function(v, x) pmax(0, x - v^3), x = 1:800)