sharon Wandia wrote: > Does anyone know how to weight cases in a data frame using a frequency > vector? > I'm trying to run tabulations on R , on a data set that first needs to have > weighted cases before i run the tabulations. > > In SPSS & SAS its quite simple, but i'm unable to do it in R.
xtabs() allows a count on the LHS of its formula argument, if you're looking at contingency tables. In other cases, an expedient, if inefficient, trick is simply to expand your data using rep(), i.e. something like mydata.x <- mydata[rep(1:nrow(mydata),mydata$count),] (Re. SPSS & SAS: what is not quite as simple is to see whether weights are frequency weights or variance weights.) -- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ 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.