# Does anyone have sample code for using svydesign function in R?

**URL:** <https://forum.ipums.org/t/does-anyone-have-sample-code-for-using-svydesign-function-in-r/2444>\
**Category:** USA\
**Created:** [July 17, 2018, 8:35pm UTC](https://forum.ipums.org/t/does-anyone-have-sample-code-for-using-svydesign-function-in-r/2444 "2018-07-17T20:35:00Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![madoolsy](https://avatars.discourse-cdn.com/v4/letter/m/a87d85/32.png) [@madoolsy](https://forum.ipums.org/u/madoolsy)\
**Post date:** [July 17, 2018, 8:35pm UTC](https://forum.ipums.org/t/does-anyone-have-sample-code-for-using-svydesign-function-in-r/2444/1 "2018-07-17T20:35:00Z")

</div>

In the “survey” vignette for R, it shows that you’re supposed to enter ID, weights, data set name, and fpc. In the example it shows the following:

dclus1 \<- svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc)

FPC is supposed to be the population size, but I do not have this variable in my dataset. What variables should I be using for id and fpc? The variables in my dataset are: year, datanum, serial, HHWT, STATEFIP, GQ, PERNUM, PERWT, AGE, HISPAN, HISPAND, RACAMIND, RACASIAN, RACBLK, RACPACIS, RACWHT, RACOTHER, POVERTY.

Does anyone have sample R code for weighting IPUMS USA data? I would like to get estimates and standard errors.

---

_[View the full topic](https://forum.ipums.org/t/does-anyone-have-sample-code-for-using-svydesign-function-in-r/2444)._
