title: Doing row/column percents with survey data in R?
body: <p>I am analyzing some survey data in R. Due to the sample design, all analysis has to be done with the "survey" package that can take the sample structure into account, which means I can't just get within-column or within-row percents using prop.table() the way I would on non-survey data.</p>
  
  <p>For anyone not familiar with the row/column percent terminology, what I mean is percents for one variable conditional on being in a specific row/column for another variable. For example:</p>
  
  <pre><code>      | male | female
  black | 10   | 20
  white | 15   | 15
  other | 10   | 15
  </code></pre>
  
  <p>A row percent would be number of observations in a cell divided by number of observations in that row, for example the percent for "male" in the row "other" is 40% (10/(10+15)). A column percent would be number of observations in a cell divided by number of observations in that column, for example the percent for "other" in the column "female" is 30% (15/(20+15+15)). Normally these are easily calculated with prop.table(), but <strong>I can't use prop.table() this time because it doesn't account for survey sample design.</strong></p>
  
  <p>I have been Googling and testing things trying to figure out how to do this with the "survey" package, and so far I have found the <a href="https://www.rdocumentation.org/packages/survey/versions/3.37/topics/svytable" rel="nofollow noreferrer">svytable()</a> function and can get it to give me a basic cross-tab of counts (eg. race by gender) but not survey-weighted percents. I have also found the <a href="https://www.rdocumentation.org/packages/survey/versions/3.37/topics/surveysummary" rel="nofollow noreferrer">svymean() and svytotal()</a> functions, but so far all I've managed to do is get univariate weighted percents from svymean() (which appears to dummy-code each category as 0/1 then take a mean), and to combine svymean with the interaction function (eg. <code>svymean(~interaction(race,gender),...)</code>) to get cell percents (eg. "black males are XX% of the total sample"), but I still can't get within-row and within-column percents.</p>
  
  <p>How do I get the "survey" package to give me survey-adjusted column and row percents for a cross-tab of two variables?</p>