[R] Quantiles from vectors

From: jimbib webber <alfieim21_at_hotmail.co.uk>
Date: Sun, 2 Dec 2007 18:07:00 +0000

Each number in the list belowresides in a quantile. When put in order, there are 10 numbers, so the first is in the 0.1 quantile, the second in the 0.2 etc.

Lets say we have 10 examples of systolic blood pressure from 30 year olds:


This is a random sample.

What I want to do is in R, calculate the corresponding quantiles from a normal distribution with the same mean and variance as the sample.

So, using the same mean and variance as the above random sample, create a normal distribution. From this normal distribution, I want to calculate 10 corresponding quantiles.

Then, I want to plot a qqplot of both data sets to see the distribution.

One idea was this:



[1] 3.76997 5.50000 7.23003

...But this does not give me 10 corresponding quantiles?

Another idea was this:

> > > x=c(104,95,106,105,110,150,101,98,85,104)

> > > n=length(x)

> > > p=(1:n-0.5)/n

> > > z=qnorm(p, mean(x), sd(x),)[order(order(x))]

But this seems to generate 10 new numbers. And not give corresponding quantiles from a normal distribution.

Any ideas?


Celeb spotting Play CelebMashup and win cool prizes

        [[alternative HTML version deleted]]

R-help_at_r-project.org 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. Received on Mon 03 Dec 2007 - 08:56:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 03 Dec 2007 - 09:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.