See which years a particular question was asked in the GSS.
gss_which_years(data, variable)
A tibble of data, usually gss_all
The variable or variables we want to check. Provide variables in tidyselect style, i.e. unquoted, and for multiple variables enclose unquoted in c()
A tibble showing whether the question or questions were asked in each of the GSS years
What years was a particular question asked in the GSS?
# \donttest{
data(gss_all)
gss_all %>%
gss_which_years(fefam)
#> # A tibble: 33 × 2
#> year fefam
#> <dbl> <lgl>
#> 1 1972 FALSE
#> 2 1973 FALSE
#> 3 1974 FALSE
#> 4 1975 FALSE
#> 5 1976 FALSE
#> 6 1977 TRUE
#> 7 1978 FALSE
#> 8 1980 FALSE
#> 9 1982 FALSE
#> 10 1983 FALSE
#> # … with 23 more rows
gss_all %>%
gss_which_years(c(industry, indus80, wrkgovt, commute))
#> # A tibble: 33 × 5
#> year industry indus80 wrkgovt commute
#> <dbl> <lgl> <lgl> <lgl> <lgl>
#> 1 1972 TRUE FALSE FALSE FALSE
#> 2 1973 TRUE FALSE FALSE FALSE
#> 3 1974 TRUE FALSE FALSE FALSE
#> 4 1975 TRUE FALSE FALSE FALSE
#> 5 1976 TRUE FALSE FALSE FALSE
#> 6 1977 TRUE FALSE FALSE FALSE
#> 7 1978 TRUE FALSE FALSE FALSE
#> 8 1980 TRUE FALSE FALSE FALSE
#> 9 1982 TRUE FALSE FALSE FALSE
#> 10 1983 TRUE FALSE FALSE FALSE
#> # … with 23 more rows
# }