[R] Simple Problem: Plotting mathematical functions

R. Michael Weylandt michael.weylandt at gmail.com
Thu Apr 12 21:59:16 CEST 2012


It seems that your first problem is syntax:

2x

will thrown an error, while

2*x

won't.

Google around for a good intro tutorial (there's the main one you can
access by typing help.start() and it's quite good) and these sorts of
things will be explained.

You might also want to use the curve function (type ?curve at the
prompt for details)

e.g.,

curve(x^2, from = 0, to = 5)

plots x^2 from x = 0 to x = 5 and handles axes nicely.

Michael

On Thu, Apr 12, 2012 at 2:29 PM, Aye <muudle at hotmail.de> wrote:
> Hey there,
> I want to plot 5 parabola functions, which happen to be
> f(x) = 0.25x² + 6,47x -32.6
> g(x)=0.99x² -6x -195
> j(x)= 0.77x² +14x -495
> k(x)=0.001x² + 65x -785
> l(x) = 0.9x² -2x -636
>
> in the same graph. Sadly I even do not really understand how to plot just
> one graph...
> I found this code in the Internet, which plots a cos-function:
>
>>x <- seq( -10, 10, length = 1000)
>>plot(x, *sin(x)*, xlab="x-values", ylab="f(x)", type="l")
>>lines(x, cos(x), lty=3)
>>title( "Trigonometric functions", "sin(x) and cos(x)")
>
> If I replace the sin(x) thing (bold) with one of my functions, it doesn't
> work and reports an unwanted character.
>
> Can somebody help me with that?
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Simple-Problem-Plotting-mathematical-functions-tp4552668p4552668.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list