I am having difficulties drawing a min, max function
1/(min(max(c * x+d, 1/a),1/b)))
.
library(ggplot2)
target <- data.frame(year = c(2011), a = c(29.82), b = c(22.27),c = c(0.0004546), d=c(0.014900))
eqs = function(x){1/(min(max(target[1,4] * x + target[1,5], 1/target[1,2]),1/target[1,3]))}
ggplot(data.frame(x=c(0,10,20,30,40,50,55,60,70, 100)), aes(x)) + stat_function(fun=eqs) + xlab("x") + ylab("y")
I only get a horizontal line at 22.27 so far.
The function itself is tested and returns the correct values when inserted e.g., eqs(50) = 26.57454
This is the desired result should be:
Anybody an idea how to do it?