I realize similar questions have already been asked already. For example, consider the one here: Equivalent of curve() for ggplot. Is it possible to plot the functions below using group
somehow or would I have to write stat_function
for each instance of a
and b
?
myfun <- function(x, i) {
sin(a[i] * x) + log(b[i] * x)
}
ggplot(data.frame(x=c(0, 10)), aes(x)) +
stat_function(fun = myfun(x, 1)) +
stat_function(fun = myfun(x, 2)) ...
What if a
and b
are big? The above seems inelegant.