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) HTH, James -- James Reilly Department of Statistics, University of Auckland Private Bag 92019, Auckland, New Zealand ______________________________________________ R-help@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.