[R] Simple Problem: Plotting mathematical functions

R. A. Bilonick rab45 at pitt.edu
Fri Apr 13 16:16:46 CEST 2012


On 04/12/2012 09:11 PM, David Winsemius wrote:
>
> On Apr 12, 2012, at 3:49 PM, Aye wrote:
>
>> Okay, i got this far:
>> f <- function(x) 0.25*x^2 + 6.47*x -32.6
>> g <- function(x) 0.99*x^2 -6*x -195
>> h <- function(x) 0.77*x^2 +14*x -495
>> j <- function(x) 0.001*x^2 + 65*x -785
>> k <- function(x) 0.9*x^2 -2*x -636
>> plot(x, f(x), xlab="Elemente in der Reihung", ylab="Indexwert des
>> Sortieraufwands"), type="l")
>> // lines(x, g(x), lty=3) //Not sure if it works, but this is 
>> irrelevant atm.
>>
>> As soon as R does the plot command, he states that x is an object he 
>> can't
>> find.
>> So i propably have to do something like x <- XXXXXXXXXX. What do I 
>> insert
>> for the XXXXXXXXX to make it have the values - say - from 15 to 10000?
>
> x <- seq(15, 1000, by=5)
>
>
>>
>> Thanks again.
>>
>> -- 
>> View this message in context: 
>> http://r.789695.n4.nabble.com/Simple-Problem-Plotting-mathematical-functions-tp4552668p4552894.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.
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> 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.

You can certainly use "plot" but you could also use "curve":

 > curve(0.25*x^2 + 6.47*x -32.6,0,10)
 > f <- function(x) 0.25*x^2 + 6.47*x -32.6
 > curve(f)
 > curve(f,0,100)

Rick

-- 
---
Richard A. Bilonick, PhD
Assistant Professor
412 647 5756
Dept. of Ophthalmology, School of Medicine
Dept. of Biostatistics, Graduate School of Public Health
Principal Investigator: Pittsburgh Aerosol Research and Inhalation Epidemiology Study (PARIES)
University of Pittsburgh



More information about the R-help mailing list