How can I build multiple functions in R?

Using ggplot, is there a way to graphically display multiple functions on the same section? I want to use the parameters from a text file as arguments for my functions and overlay them on the same plot.

I understand this one , but I don't know how to add a rendered function together if I go through.

+4
source share
1 answer

Here's a realization of Hadley’s idea.

library(ggplot2) funcs <- list(log,function(x) x,function(x) x*log(x),function(x) x^2, exp) cols <-heat.colors(5,1) p <-ggplot()+xlim(c(1,10))+ylim(c(1,10)) for(i in 1:length(funcs)) p <- p + stat_function(aes(y=0),fun = funcs[[i]], colour=cols[i]) print(p) 
+6
source

Source: https://habr.com/ru/post/1300874/


All Articles