[R] Fw: Re: Multiple Normal Curves
Jim Lemon
jim at bitwrit.com.au
Thu Sep 24 13:53:50 CEST 2009
On 09/24/2009 08:57 PM, KABELI MEFANE wrote:
> Sorry about the subject
>
> --- On Thu, 24/9/09, KABELI MEFANE<kabelimefane at yahoo.co.uk> wrote:
>
>
> From: KABELI MEFANE<kabelimefane at yahoo.co.uk>
> Subject: Re: [R] Multiply Normal Curves
> To: R-help at r-project.org
> Date: Thursday, 24 September, 2009, 11:48 AM
>
>
> R -helpers
>
> i have been trying to do this problem without must success,i managed to do a graph for x, but it is not what i want to define,(i want to specify number of observations as well). I have also been able to do simple rendom sample.
>
> data.frame(ID=c(1,2,3),mu=c(10000,34000,50000),sigma=c(2000,3000,5000))
> curve(dnorm(x,mean=parms$mu[1],sd=parms$sigma[1]),from=2000,
> to=80000, ylab="density", col="red")
> curve(dnorm(x,mean=parms$mu[2],sd=parms$sigma[2]),from=1000,
> to=80000, ylab="density", col="blue", add=TRUE)
> curve(dnorm(x,mean=parms$mu[3],sd=parms$sigma[3]),from=1000,
> to=80000, ylab="density", col="forestgreen", add=TRUE)
> ###
>
> R-helpers
>
> I have been learning a little bit of R. I am simulating and i want to draw a normal curve for all my variables so that i will see the overlaps and reduce them, after that i want to draw a gragh of all the values that are in the data frame to see if it follows a normal distribution also. Lastly i will try to sample from this data. Please help and make suggestions.
>
>
Hi Kabeli,
I think you want to get multiple histograms and normal curves on the
same plot. You can do something like that if you get a table of
frequencies for each of your three sets of values using "cut" or "hist",
combine these vectors of frequencies into a matrix and pass this to
barplot. Then draw your normal curves using "curve" on top of the
grouped bars.
Jim
More information about the R-help
mailing list