# [R] Compute quantiles with values and correspondent frequencies

Fri Mar 3 13:30:11 CET 2006

```Yes, but it works only when you have integer counts for each value.
When I have only relative frequencies I can't repeat each value a
non-integer number of times.
Paolo

----- Original Message -----
From: "Roger Bivand" <Roger.Bivand at nhh.no>
Cc: <r-help at stat.math.ethz.ch>
Sent: Friday, March 03, 2006 1:18 PM
Subject: Re: [R] Compute quantiles with values and correspondent frequencies

> On Fri, 3 Mar 2006, Paolo Radaelli wrote:
>
> > Dear List, quantile(x) function allows to obtain specified quantiles of
> > a vector of observations x.
> >
> > Is there an analogous function to compute quantiles in the case one have
> > the vector of the observations x and the correspondent vector f of
> > relative frequencies ?
>
> Just use rep():
>
> x <- rpois(100, 4) # data
> quantile(x)
> tx <- table(x) # frequencies (need to be integer counts)
> tx
> v <- as.numeric(names(tx)) # values
> quantile(rep(v, as.integer(tx)))
>
> You have v and tx, so this should work.
>
> >
> > Thank you
> >
> >
> >
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
http://www.R-project.org/posting-guide.html
> >
>
> --
> Roger Bivand
> Economic Geography Section, Department of Economics, Norwegian School of