Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

How to find the frequency of second histogram based on quantile of first

$
0
0

I have two sets of data. In the first set I can calculate the 25th percentile and output the x value. I would then like to take that x value to a second data set and determine the frequency and percentile at the same point.

As an example, here is some code based on a random variate (the actual data is not random)

data1 = rnorm(10000, mean=8, sd=1.3)
data2 = rnorm(10000, mean=4, sd=1.0)

#plot data1 histogram with 40 bins
hist(data1, breaks=40, col="red", xlim=c(2,14), ylim=c(0,800),
     main="Gaussian deviates :  mean=8, sigma=1.3", col.main="blue")
segments(quantile(data1,0.25), 0, quantile(data1,0.25), 600, col="green", lwd=4, lty=1)

#plot data2 histogram with 40 bins
hist(data2, breaks=40, col="red", xlim=c(2,14), ylim=c(0,900),
     main="Gaussian deviates :  mean=4, sigma=1.0", col.main="blue")
print(quantile(data1,0.25))

Viewing all articles
Browse latest Browse all 201839

Trending Articles