[R] plotting gaussian data

H. Paul Benton hpbenton at scripps.edu
Tue Jun 13 08:42:07 CEST 2006


Ok I guess it's time to ask. 
So I want to plot my data. It's my data from a frequency table, "temp". My
formula is just a Gaussian eq. I have done the nls function to get my
parameters and now I want to do the whole plot (...) and then lines(..)
This is what I have done. 

> temp
    bin   x
1  -4.0   0
2  -3.9   0
3  -3.8   0
4  -3.7   0
5  -3.6   0
6  -3.5   0 .... and so on
> fo
x ~ (A/(sig * sqrt(2 * pi))) * exp(-1 * ((bin - mu)^2/(2 * sig^2)))
> fo.v
x ~ (335.48/(0.174 * sqrt(2 * pi))) * exp(-1 * ((bin - (-0.0786))^2/(2 * 
    0.174^2)))
> coef
$A
[1] 335.4812

$mu
[1] -0.07863746

$sig
[1] 0.1746473

plot(fo, temp, coef)
Error in eval(expr, envir, enclos) : object "sig" not found
> plot(fo, coef, temp)
Error in eval(expr, envir, enclos) : object "x" not found
> plot(fo, temp, list=coef)
>

If someone could point me in the right direction I would be very grateful. 

Cheers,



More information about the R-help mailing list