Get marginal summaries for a GSS variable or variables

gss_get_marginals(varnames = "id", data = gss_doc, margin = marginals)

Arguments

varnames

The (categorical) variable or variables you want to see marginals for. Can be a character string or a character vector.

data

The codebook data frame, by default gss_doc, or alternatively the wide panel documentation in gss_panel_docw.

margin

Which margin. Not needed for gss_doc, but one of marginals_1, marginals_2, or marginals_2 when data is gss_panel_docw.

Value

A tibble of marginal distributions from the GSS codebook

Details

Codebook summaries from the gss_doc or gss_panel_docw objects

Author

Kieran Healy

Examples

# \donttest{
data(gss_doc)
gss_get_marginals(varnames = "race")
#> # A tibble: 4 × 6
#>   variable percent     n value label id   
#>   <chr>      <dbl> <int> <chr> <chr> <chr>
#> 1 race        80.3 52033 1     WHITE RACE 
#> 2 race        14.2  9187 2     BLACK RACE 
#> 3 race         5.5  3594 3     OTHER RACE 
#> 4 race       100   64814 NA    Total RACE 

gss_get_marginals(varnames = c("race", "gender", "fefam"))
#> # A tibble: 12 × 6
#>    variable percent     n value label             id   
#>    <chr>      <dbl> <int> <chr> <chr>             <chr>
#>  1 race        80.3 52033 1     WHITE             RACE 
#>  2 race        14.2  9187 2     BLACK             RACE 
#>  3 race         5.5  3594 3     OTHER             RACE 
#>  4 race       100   64814 NA    Total             RACE 
#>  5 fefam        8.5  2543 1     STRONGLY AGREE    FEFAM
#>  6 fefam       29.9  8992 2     AGREE             FEFAM
#>  7 fefam       43.4 13061 3     DISAGREE          FEFAM
#>  8 fefam       18.2  5479 4     STRONGLY DISAGREE FEFAM
#>  9 fefam       NA   34111 0     IAP               FEFAM
#> 10 fefam       NA     534 8     DK                FEFAM
#> 11 fefam       NA      94 9     NA                FEFAM
#> 12 fefam      100   64814 NA    Total             FEFAM
# }