Re: [R] 4 questions regarding hypothesis testing, survey package, ts on samples, plotting

From: James Reilly <>
Date: Wed, 19 Dec 2007 22:50:00 +1300

On 19/12/07 8:39 PM, eugen pircalabelu wrote:
> 2. How can i find the median of a variable in survey package?
> a<-c(1:10)
> b<-sample(1:20, 10, replace=T)
> b1<-sample(0:1, 10, replace=T)
> c<-data.frame(a,b, b1)
> library(survey)
> design<-svydesign(id=~1, data=c)
> svymean(~b, design)
> svymean gives me the mean, but what function gives me the svymedian, and what function gives me the svyproportion for b1?
> I want to know the median for a metric variable and the proportion for a binomial variable ?

The svyquantile function will give you the median, e.g. svyquantile(~b, design, 0.5, interval.type="score")

Since a proportion is just the mean of a 0/1 variable, you can use svymean for that, e.g.
svymean(~b1, design)


James Reilly
Department of Statistics, University of Auckland
Private Bag 92019, Auckland, New Zealand

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 19 Dec 2007 - 09:54:41 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 Wed 19 Dec 2007 - 10:30:20 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.