Hi Jim
 
Sorry to bother you but i don't seem to understand what you are saying. I have 
the simulated data as follows:
 
Hypermarket <- matrix(rnorm(100, mean=50000, sd=5000))
Supermarket <- matrix(rnorm(400, mean=34000, sd=3000))
Minimarket  <- matrix(rnorm(1000, mean=10000,sd=2000))
Cornershop  <- matrix(rnorm(1500, mean=2500, sd=500))
Spazashop   <- matrix(rnorm(2000, mean=1000, sd=250))
dat=data.frame(type=c(rep("Hypermarket",100), rep("Supermarket",400),
rep("Minimarket",1000),rep("Cornershop",1500), rep("Spazashop",2000)),
value=c(Hypermarket, Supermarket, Minimarket, Cornershop,Spazashop))
 
Now, i want to do multiple histograms and normal curves on the same plot as you 
rightfully pointed out, but i cannot plot all of them even when i have done the 
following i can only do one. 

Hypermarket<-rnorm(100, mean=50000, sd=3000)
par(las=1)
hist(Hypermarket, breaks=seq(0, 60000, 500), freq=F)
x<- seq(0, 60000, 1000)
lines(x, dnorm(x, 50000, 3000))
 
As for the code below, i dicided to leave it as i does not allow me to do more 
than three curves. 
 
I would appreciate all the help.

Kabeli

--- On Thu, 24/9/09, Jim Lemon <[email protected]> wrote:


From: Jim Lemon <[email protected]>
Subject: Re: [R] Fw: Re: Multiple Normal Curves
To: "KABELI MEFANE" <[email protected]>, [email protected]
Date: Thursday, 24 September, 2009, 12:53 PM


On 09/24/2009 08:57 PM, KABELI MEFANE wrote:
> Sorry about the subject
> 
> --- On Thu, 24/9/09, KABELI MEFANE<[email protected]>  wrote:
> 
> 
> From: KABELI MEFANE<[email protected]>
> Subject: Re: [R] Multiply Normal Curves
> To: [email protected]
> 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




      
        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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.

Reply via email to