Description Usage Arguments Value Examples
Weighted sums by rotation groups
1 2 3 4 5 6 7 8 |
list.tables |
a named list of data frames |
weight |
a character string indicating the variable name or a numerical value |
list.y |
a vector of character strings indicating the study variables |
rg |
a character string indicating the name of the rotation group. |
an array
1 2 3 4 5 6 7 8 9 10 11 12 | library(dataCPS)
period<-200501:200512
list.tables<-lapply(data(list=paste0("cps",period),package="dataCPS"),get);
names(list.tables)<-period
Y<-WSrg(list.tables,"pwsswgt",list.y="pemlr",rg="hrmis")
dimnames(Y);dim(Y)
Y<-plyr::daply(plyr::ldply(list.tables,function(L){L[c("pemlr","pwsswgt","hrmis")]},.id="m"),
~m+pemlr+hrmis,function(d){data.frame(y=sum(d$pwsswgt))})[names(list.tables),,]
dimnames(Y);dim(Y)
system.time(plyr::daply(plyr::ldply(list.tables,,function(L){L[c("pemlr","pwsswgt","hrmis")]}),
~.id+pemlr+hrmis,function(d){data.frame(y=sum(d$pwsswgt))}))
system.time(WSrg(list.tables,weight="pwsswgt",list.y="pemlr",rg="hrmis"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.