I find that looking at the help(svydesign)
example helped me to understand at least where the weight argument comes from—it's in the data
object. So the weights
argument here has to come from api
because nothing else is in scope. After data(api)
it appears that there are four objects brought into scope and apistrat
is one of them and that supplies the data
argument.
The other arguments must derive from apistrat
because nothing by their names are yet in namespace. So, I look with apistrat()
and find them. Why those particular values I have no idea; that's a domain question.
library(survey)
#> Loading required package: grid
#> Loading required package: Matrix
#> Loading required package: survival
#>
#> Attaching package: 'survey'
#> The following object is masked from 'package:graphics':
#>
#> dotchart
data(api)
# stratified sample example from help(svydesign)
dstrat<-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
colnames(apistrat)
#> [1] "cds" "stype" "name" "sname" "snum" "dname"
#> [7] "dnum" "cname" "cnum" "flag" "pcttest" "api00"
#> [13] "api99" "target" "growth" "sch.wide" "comp.imp" "both"
#> [19] "awards" "meals" "ell" "yr.rnd" "mobility" "acs.k3"
#> [25] "acs.46" "acs.core" "pct.resp" "not.hsg" "hsg" "some.col"
#> [31] "col.grad" "grad.sch" "avg.ed" "full" "emer" "enroll"
#> [37] "api.stu" "pw" "fpc"
Created on 2022-12-23 by the reprex package (v2.0.1)