svydbby: Survey statistics on subsets

Description Usage Arguments Author(s) See Also Examples

View source: R/svydbby.R

Description

Survey statistics on subsets, currently only works on svydbtotal, svydbmean.

Usage

1
svydbby(x, by, FUN, design, ...)

Arguments

x

A variable specifying the variable to pass to FUN.

by

A variable specifying factors that define the subsets.

FUN

A function indicating the desired survey statistics.

design

svydb.design object.

...

Other arguments to pass to FUN.

Author(s)

Charco Hui

See Also

svydbdesign, svydbtotal, svydbmean

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data(nhane)
nh.dbsurv = svydbdesign(st = SDMVSTRA, wt = WTMEC2YR, id = SDMVPSU, data = nhane)
svydbby(x = Age, by = Gender, FUN = svydbmean, design = nh.dbsurv, num = T)
svydbby(x = BMI, by = Race3, FUN = svydbtotal, design = nh.dbsurv, num = T)
# OR with a database connection
# library(MonetDBLite)
# library(DBI)
# library(dbplyr)
# con = dbConnect(MonetDBLite())
# dbWriteTable(con, "nhane", nhane)
# nhane.db = tbl(con, "nhane")
# nh.dbsurv = svydbdesign(st = SDMVSTRA, wt = WTMEC2YR, id = SDMVPSU, data = nhane.db)

chrk623/svydb documentation built on Oct. 6, 2019, 6:54 a.m.