[R] Simple Problem: Plotting mathematical functions
Matthieu Dubois
matthdub at gmail.com
Thu Apr 12 22:11:25 CEST 2012
Hi,
you can use the curve() function for this. It is dedicated to plotting
functions.
Here is an example
# turn your functions into r functions
f <- function(x) 0.25 * x^2 + 6.47 * x -32.6
g <- function(x) 0.99*x^2 -6*x -195
j <- function(x) 0.77*x^2 + 14*x -495
k <- function(x) 0.001*x^2 + 65*x -785
l <- function(x) 0.9*x^2 -2*x -636
# plot f and g
curve(f, from=0, to=100, lty=1)
curve(g, add=TRUE, lty=2)
In this example, the parameters 'from' and 'to' define the domain over wich
all functions will be evaluated. The parameter add=TRUE is used to add
the second function to the previous plot.
HTH
Matthieu
Matthieu Dubois
Post-doctoral fellow,
Psychology Department, Univeristé Libre de Bruxelles
More information about the R-help
mailing list