plot two histograms together in R

Considering two samples of datas A and B. To plot histograms together in the same window 
just run the following commands (in the R Console) 
 
hist(A,col="red")
hist(B, col="blue",add=T)
 
Example: 
 
b=rnorm(2000, 6, 1)
a=rnorm(2000, 3, 1)
hist(a,col="red",ylim=c(0,400))
hist(b,col="blue",ylim=c(0,400),add=T)  # add=T is the key
 

Commentaires

Articles les plus consultés