Skip to contents

Print a transposed summary of the survey object's columns — column names run down the left, data types and values run across. Respects select(): if columns have been selected, only those columns are shown; design variables are hidden from the display.

Usage

# S3 method for class 'survey_collection'
glimpse(x, width = NULL, ..., .by_survey = FALSE)

glimpse(x, width = NULL, ...)

# S3 method for class 'survey_base'
glimpse(x, width = NULL, ...)

Arguments

x

A survey_base object.

width

Width of the output. Defaults to the console width.

...

Passed to dplyr::glimpse().

.by_survey

If TRUE, render a separate labelled glimpse block per member, prefixed by the member name. Default FALSE renders a single bound tibble with the source survey id prepended as coll@id (default .survey).

Value

x invisibly.

x invisibly.

Survey collections

Default mode binds every member's @data into a single tibble (via dplyr::bind_rows() with .id = coll@id) and glimpses the result. If any member's @data already contains a column named coll@id, the surveytidy_error_collection_glimpse_id_collision error is raised BEFORE binding — symmetric with surveycore's surveycore_error_collection_id_collision for the construction-time case. Resolve by renaming the colliding column or setting a different coll@id via surveycore::set_collection_id().

Internal column rename: when the member @data contains surveycore::SURVEYCORE_DOMAIN_COL (..surveycore_domain..), the column is renamed to .in_domain for the rendered output. Per-member @data is untouched.

Type-coercion footer: when bind_rows() coerces conflicting types across members (e.g., <chr> vs <dbl>), a footer enumerates the affected columns. Truncates after 5 columns; line width capped at 80 characters. No opt-out — the footer renders only when conflicts exist.

See also

select() to control which columns are visible

Other selecting: pull.survey_collection(), relocate, select

Examples

library(surveytidy)
library(surveycore)

# create a survey design from the pew_npors_2025 example dataset
d <- as_survey(pew_npors_2025, weights = weight, strata = stratum)

# glimpse all columns
glimpse(d)
#> Rows: 5,022
#> Columns: 65
#> $ respid            <dbl> 1470, 2374, 1177, 15459, 9849, 8178, 3682, 6999, 994…
#> $ mode              <dbl> 2, 2, 3, 2, 1, 3, 1, 2, 2, 1, 2, 2, 2, 1, 2, 2, 1, 1…
#> $ language          <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ languageinitial   <dbl> NA, NA, 10, NA, 9, 9, 9, NA, NA, 9, NA, NA, NA, 9, N
#> $ stratum           <dbl> 10, 7, 5, 10, 9, 10, 4, 10, 10, 10, 10, 10, 9, 10, 9…
#> $ interview_start   <date> 2025-05-27, 2025-05-01, 2025-03-04, 2025-05-05, 202…
#> $ interview_end     <date> 2025-05-27, 2025-05-01, 2025-03-04, 2025-05-05, 202…
#> $ econ1mod          <dbl> 4, 3, 2, 3, 2, 2, 3, 3, 3, 1, 2, 2, 4, 4, 2, 4, 2, 3…
#> $ econ1bmod         <dbl> 2, 2, 1, 3, 1, 2, 2, 3, 2, 1, 3, 3, 3, 2, 1, 2, 3, 3…
#> $ comtype2          <dbl> 3, 1, 3, 3, 2, 1, 1, 3, 3, 2, 3, 1, 1, 3, 2, 1, 2, 1…
#> $ unity             <dbl> 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2…
#> $ crimesafe         <dbl> 2, 3, 2, 2, 3, 2, 3, 3, 3, 2, 3, 2, 2, 2, 2, 2, 2, 4…
#> $ govprotct         <dbl> 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2…
#> $ moregunimpact     <dbl> 1, 3, 2, 3, 2, 2, 1, 3, 2, 2, 3, 3, 2, 3, 3, 1, 1, 3…
#> $ fin_sit           <dbl> 3, 3, 3, 4, 1, 1, 2, 2, 3, 2, 2, 2, 4, 3, 3, 1, 2, 2…
#> $ vet1              <dbl> 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 1…
#> $ vol12_cps         <dbl> 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 2, 2…
#> $ eminuse           <dbl> 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ intmob            <dbl> 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ intfreq           <dbl> 2, 2, 2, 2, 2, 6, 2, 3, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2…
#> $ intfreq_collapsed <dbl> 2, 2, 2, 2, 2, 4, 2, 3, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2…
#> $ home4nw2          <dbl> 1, 1, 1, 2, 1, NA, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
#> $ bbhome            <dbl> 2, 2, 2, NA, 2, NA, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
#> $ smuse_fb          <dbl> 2, 1, 1, 2, 1, NA, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 
#> $ smuse_yt          <dbl> 1, 1, 1, 1, 1, NA, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
#> $ smuse_x           <dbl> 2, 2, 1, 2, 1, NA, 2, 1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 
#> $ smuse_ig          <dbl> 2, 1, 1, 2, 1, NA, 1, 2, 2, 1, 2, 2, 1, 1, 2, 1, 1, 
#> $ smuse_sc          <dbl> 2, 2, 2, 2, 1, NA, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 1, 
#> $ smuse_wa          <dbl> 2, 2, 1, 2, 2, NA, 1, 2, 2, 1, 2, 2, 2, 2, 2, 1, 1, 
#> $ smuse_tt          <dbl> 2, 1, 2, 2, 2, NA, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1, 
#> $ smuse_rd          <dbl> 1, 2, 2, 2, 2, NA, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 
#> $ smuse_bsk         <dbl> 2, 2, 2, 2, 2, NA, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
#> $ smuse_th          <dbl> 2, 2, 2, 2, 2, NA, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
#> $ smuse_ts          <dbl> 2, 2, 1, 2, 2, NA, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
#> $ radio             <dbl> 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2…
#> $ device1a          <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ smart2            <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ nhisll            <dbl> 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2…
#> $ relig             <dbl> 12, 1, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 12, 1, 2, 2, 6,
#> $ religcat1         <dbl> 3, 1, 1, 1, 1, 2, 2, 1, 1, 2, 1, 1, 3, 1, 2, 2, 4, 3…
#> $ born              <dbl> 2, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 1, 2, 2, 2, 2…
#> $ attendper         <dbl> 6, 6, 5, 5, 2, 4, 4, 5, 1, 5, 3, 4, 6, 2, 5, 2, 2, 6…
#> $ attendonline2     <dbl> 6, 6, 1, 5, 4, 6, 6, 6, 3, 3, 5, 3, 6, 3, 5, 6, 1, 6…
#> $ relimp            <dbl> 4, 3, 1, 1, 1, 4, 1, 2, 1, 2, 1, 1, 4, 1, 2, 1, 1, 4…
#> $ pray              <dbl> 7, 6, 2, 2, 1, 6, 2, 2, 1, 2, 2, 3, 7, 1, 2, 1, 4, 6…
#> $ educcat           <dbl> 1, 2, 2, 2, 1, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 1, 3…
#> $ registration      <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1…
#> $ party             <dbl> 3, 2, 1, 1, 1, 1, 3, 3, 3, 2, 1, 1, 2, 1, 1, 2, 3, 2…
#> $ partyln           <dbl> 2, NA, NA, NA, NA, NA, 2, 1, 1, NA, NA, NA, NA, NA, 
#> $ partysum          <dbl> 2, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2…
#> $ hisp              <dbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2…
#> $ racecmb           <dbl> 4, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 5, 1, 1, 1, 3, 1…
#> $ racethn           <dbl> 4, 2, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1, 3, 1, 1, 3, 5, 1…
#> $ agegrp            <dbl> 11, 10, 10, 6, 10, 13, 7, 13, 9, 6, 8, 11, 7, 7, 11,
#> $ agecat            <dbl> 4, 4, 4, 2, 4, 4, 3, 4, 3, 2, 3, 4, 3, 3, 4, 2, 1, 4…
#> $ birthplace        <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1…
#> $ gender            <dbl> 2, 1, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 1…
#> $ adults            <dbl> 1, 4, 2, 2, 4, 2, 3, 2, 2, 3, 3, 1, 99, 3, 1, 2, 2, 
#> $ voted2024         <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1…
#> $ votegen_post      <dbl> 2, 2, 1, 1, 1, 99, 2, 1, 1, 2, 3, 1, 2, 1, 1, 2, NA,
#> $ inc_sdt1          <dbl> 2, 5, 2, 1, 8, 99, 6, 5, 4, 7, 4, 4, 3, 5, 1, 8, 5, 
#> $ cregion           <dbl> 4, 4, 4, 2, 1, 2, 3, 4, 3, 4, 3, 3, 4, 3, 1, 3, 1, 3…
#> $ metro             <dbl> 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ basewt            <dbl> 0.8022005, 0.5324945, 1.2496416, 1.6044009, 0.676350…
#> $ weight            <dbl> 0.4970381, 0.3070815, 0.6468503, 1.3112448, 0.241760…

# after select(), shows only the selected columns
d |>
  select(gender, agecat, partysum) |>
  glimpse()
#> Rows: 5,022
#> Columns: 3
#> $ gender   <dbl> 2, 1, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 1, 2, 2, 2…
#> $ agecat   <dbl> 4, 4, 4, 2, 4, 4, 3, 4, 3, 2, 3, 4, 3, 3, 4, 2, 1, 4, 2, 2, 4…
#> $ partysum <dbl> 2, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 1…