Skip to contents

Replace the number of weights taken into account with the number of n in the original data

Usage

ChangeSvyTable(svy, ori)

Arguments

svy

TableOne object that take weights into account

ori

TableOne object in the original data

Value

A matrix that replaces the n number of weights with the n number of the original data

Details

DETAILS

Examples

# example code
library('survey'); library('tableone')
#> 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(nhanes)
nhanes$SDMVPSU <- as.factor(nhanes$SDMVPSU)
nhanesSvy <- svydesign(
  ids = ~SDMVPSU, strata = ~SDMVSTRA, weights = ~WTMEC2YR,
  nest = TRUE, data = nhanes
)

res <- svyCreateTableOne(
  vars = c("HI_CHOL", "race", "agecat", "RIAGENDR"),
  strata = "RIAGENDR", data = nhanesSvy,
  factorVars = c("HI_CHOL", "race", "RIAGENDR")
)

ori <- CreateTableOne(
  vars = c("HI_CHOL", "race", "agecat", "RIAGENDR"),
  strata = "RIAGENDR", data = nhanes,
  factorVars = c("HI_CHOL", "race", "RIAGENDR")
)
ChangeSvyTable(res, ori)
#>                   Stratified by RIAGENDR
#>                    1              2               p      test
#>   n                4247.0         4344.0                     
#>   HI_CHOL = 1 (%)   363.0 (10.1)   424.0 ( 12.3)   0.010     
#>   race (%)                                         0.042     
#>      1             1339.0 (15.8)  1378.0 ( 14.3)             
#>      2             1863.0 (66.2)  1880.0 ( 65.3)             
#>      3              798.0 (11.1)   825.0 ( 12.7)             
#>      4              247.0 ( 6.8)   261.0 (  7.7)             
#>   agecat (%)                                       0.001     
#>      (0,19]        1318.0 (21.7)  1214.0 ( 19.9)             
#>      (19,39]        953.0 (30.0)  1080.0 ( 28.7)             
#>      (39,59]        995.0 (30.4)  1026.0 ( 30.2)             
#>      (59,Inf]       981.0 (17.9)  1024.0 ( 21.2)             
#>   RIAGENDR = 2 (%)    0.0 ( 0.0)  4344.0 (100.0)  <0.001