I have 3 vectors of equal length y, hand hp, defined as follows:
y <- c(2, 5, 6)
h <- c(4, 25, 35)
hp <- c(3, 10, 12)
The values ββare merely illustrative.
I want to create an output function list final_list in the xfollowing way
function(x) y + (h - hp) * x
(only the perfect illustrative result is displayed):
[[1]]
[1] function(x) 2 + (1) * x
[[2]]
[1] function(x) 5 + (15) * x
[[3]]
[1] function(x) 6 + (23) * x
I know that this can be done using eval / parse, but it does not produce transparent output for functions.
I would like to create functions from these 3 vectors and output without using eval / parse. If possible, I would be very happy to know and be impressed!
source
share