# Chapter 3 Codebook

This chapter displays the codebook for the data set of the first Good Loser experiment, automatically generated using the R package “codebook”.

``if(!require("codebook")){install.packages("codebook");  library(codebook)}``
``## Loading required package: codebook``
``if(!require("haven")){install.packages("haven");  library(haven)}``
``````d <- read_sav("C:\\Users/Sveinung/OneDrive/NORCE 2018-/goodloser/Conjoint/Bookdown-goodloser/Data/Goodloser-exp1.sav")

detect_missings(d, ninety_nine_problems = TRUE, negative_values_are_missing = TRUE)``````
``````## # A tibble: 1,019 x 14
##      Q64 Q63   S3_1_1 S3_2_1 S3_4_1_1 S3_4_1_2 S3_5_1 S3_6_1_1 S3_6_1_2
##    <dbl> <dbl> <dbl+> <dbl+> <dbl+lb> <dbl+lb> <dbl+> <dbl+lb> <dbl+lb>
##  1    52 2     1      5      1        NA       4      1        NA
##  2    30 2     2      3      4        NA       4      5        NA
##  3    64 2     1      4      5        NA       2      2        NA
##  4    43 2     2      2      4        NA       4      7        NA
##  5    74 1     2      7      4        NA       4      4        NA
##  6    51 2     1      4      1        NA       1      4        NA
##  7    58 1     2      7      7        NA       7      6        NA
##  8    55 1     2      4      4        NA       4      6        NA
##  9    68 2     2      3      3        NA       3      3        NA
## 10    32 1     2      5      6        NA       6      5        NA
## # ... with 1,009 more rows, and 5 more variables: S3_7_1_1 <dbl+lbl>,
## #   S3_7_1_2 <dbl+lbl>, S3_8_1_1 <dbl+lbl>, S3_8_1_2 <dbl+lbl>,
## #   Studie3sel <dbl+lbl>``````
``codebook(d)``
``````## Warning in codebook(d): The variables session, created, ended have to
## be defined for automatic survey repetition detection to work. Set to no
## repetition by default.``````
``knitr::asis_output(survey_overview)``

## 3.1 Items

``knitr::asis_output(paste0(scales_items, sep = "\n\n\n", collapse = "\n\n\n"))``

### 3.1.1 Q64

Ålder

#### 3.1.1.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

4 missings.

#### 3.1.1.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
``````## Warning: Prefixing `UQS()` with the rlang namespace is deprecated as of rlang 0.3.0.
## Please use the non-prefixed form or `!!!` instead.
##
##   rlang::expr(mean(rlang::UQS(args)))
##
##   # Ok:
##   rlang::expr(mean(UQS(args)))
##
##   # Good:
##   rlang::expr(mean(!!!args))
##
## This warning is displayed once per session.``````
name label data_type missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss display_width
Q64 Ålder numeric 4 1015 1019 52.46 17.74 18 38 54 68 86 ▅▅▅▆▆▇▆▂ F8.0 10
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````
``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````

### 3.1.2 Q63

Kön

#### 3.1.2.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

0 missings.

#### 3.1.2.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss display_width
Q63 Kön numeric 1. Man,
2. Kvinna
0 1019 1019 1.52 0.5 1 1 2 2 2 ▇▁▁▁▁▁▁▇ F1.0 12
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.2.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• Man: 1
• Kvinna: 2

### 3.1.3 S3_1_1

I debatten diskuteras ibland att kommunerna skall kunna förbjuda tiggeri inom sina gränser. Vad tycker du själv om att förbjuda tiggeri i kommunen där du bor?

#### 3.1.3.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

0 missings.

#### 3.1.3.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss display_width
S3_1_1 I debatten diskuteras ibland att kommunerna skall kunna förbjuda tiggeri inom sina gränser. Vad tycker du själv om att förbjuda tiggeri i kommunen där du bor? numeric 1. Jag är huvudsakligen emot att förbjuda tiggeri i min kommun,
2. Jag är huvudsakligen för att förbjuda tiggeri i min kommun
0 1019 1019 1.56 0.5 1 1 2 2 2 ▆▁▁▁▁▁▁▇ F1.0 12
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.3.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• Jag är huvudsakligen emot att förbjuda tiggeri i min kommun: 1
• Jag är huvudsakligen för att förbjuda tiggeri i min kommun: 2

### 3.1.4 S3_2_1

Hur viktig är frågan för dig personligen?

#### 3.1.4.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

0 missings.

#### 3.1.4.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss display_width
S3_2_1 Hur viktig är frågan för dig personligen? numeric 1. 1 Inte alls viktig,
2. 2,
3. 3,
4. 4,
5. 5,
6. 6,
7. 7 Mycket viktig
0 1019 1019 4.04 1.79 1 3 4 5 7 ▃▆▇▇▁▇▅▅ F1.0 12
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.4.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• 1 Inte alls viktig: 1
• 2: 2
• 3: 3
• 4: 4
• 5: 5
• 6: 6
• 7 Mycket viktig: 7

### 3.1.5 S3_4_1_1

Hur rättvist tycker du att det gick till när det fattades beslut om att förbjuda tiggeri?

#### 3.1.5.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

496 missings.

#### 3.1.5.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss display_width
S3_4_1_1 Hur rättvist tycker du att det gick till när det fattades beslut om att förbjuda tiggeri? numeric 1. 1 Inte alls rättvist,
2. 2,
3. 3,
4. 4,
5. 5,
6. 6,
7. 7 Mycket rättvist
496 523 1019 4.32 1.81 1 3 4 6 7 ▃▃▅▇▁▆▅▆ F1.0 12
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.5.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• 1 Inte alls rättvist: 1
• 2: 2
• 3: 3
• 4: 4
• 5: 5
• 6: 6
• 7 Mycket rättvist: 7

### 3.1.6 S3_4_1_2

Hur rättvist tycker du att det gick till när det fattades beslut om att inte förbjuda tiggeri?

#### 3.1.6.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

523 missings.

#### 3.1.6.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss
S3_4_1_2 Hur rättvist tycker du att det gick till när det fattades beslut om att inte förbjuda tiggeri? numeric 1. 1 Inte alls rättvist,
2. 2,
3. 3,
4. 4,
5. 5,
6. 6,
7. 7 Mycket rättvist
523 496 1019 4.4 1.89 1 3 4 6 7 ▃▂▅▇▁▅▅▆ F1.0
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.6.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• 1 Inte alls rättvist: 1
• 2: 2
• 3: 3
• 4: 4
• 5: 5
• 6: 6
• 7 Mycket rättvist: 7

### 3.1.7 S3_5_1

Och hur schysst tycker du att beslutsproceduren var?

#### 3.1.7.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

0 missings.

#### 3.1.7.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss display_width
S3_5_1 Och hur schysst tycker du att beslutsproceduren var? numeric 1. 1 Mycket oschysst,
2. 2,
3. 3,
4. 4,
5. 5,
6. 6,
7. 7 Mycket schysst
0 1019 1019 4.21 1.71 1 3 4 5 7 ▂▂▅▇▁▆▃▃ F1.0 12
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.7.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• 1 Mycket oschysst: 1
• 2: 2
• 3: 3
• 4: 4
• 5: 5
• 6: 6
• 7 Mycket schysst: 7

### 3.1.8 S3_6_1_1

Och om du tänker på själva beslutet att förbjuda tiggeri. Vad tycker Du allmänt sett om beslutet?

#### 3.1.8.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

496 missings.

#### 3.1.8.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss display_width
S3_6_1_1 Och om du tänker på själva beslutet att förbjuda tiggeri. Vad tycker Du allmänt sett om beslutet? numeric 1. 1 Mycket dåligt,
2. 2,
3. 3,
4. 4,
5. 5,
6. 6,
7. 7 Mycket bra
496 523 1019 4.38 2.13 1 2 5 6 7 ▆▃▃▆▁▅▆▇ F1.0 12
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.8.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• 1 Mycket dåligt: 1
• 2: 2
• 3: 3
• 4: 4
• 5: 5
• 6: 6
• 7 Mycket bra: 7

### 3.1.9 S3_6_1_2

Och om du tänker på själva beslutet att inte förbjuda tiggeri. Vad tycker Du allmänt sett om beslutet?

#### 3.1.9.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

523 missings.

#### 3.1.9.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss
S3_6_1_2 Och om du tänker på själva beslutet att inte förbjuda tiggeri. Vad tycker Du allmänt sett om beslutet? numeric 1. 1 Mycket dåligt,
2. 2,
3. 3,
4. 4,
5. 5,
6. 6,
7. 7 Mycket bra
523 496 1019 3.92 2.01 1 2 4 6 7 ▇▆▇▇▁▅▅▇ F1.0
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.9.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• 1 Mycket dåligt: 1
• 2: 2
• 3: 3
• 4: 4
• 5: 5
• 6: 6
• 7 Mycket bra: 7

### 3.1.10 S3_7_1_1

Hur villig är du att acceptera och följa beslutet att förbjuda tiggeri?

#### 3.1.10.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

496 missings.

#### 3.1.10.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss display_width
S3_7_1_1 Hur villig är du att acceptera och följa beslutet att förbjuda tiggeri? numeric 1. 1 Inte alls villig,
2. 2,
3. 3,
4. 4,
5. 5,
6. 6,
7. 7 Mycket villig
496 523 1019 5.1 1.97 1 4 6 7 7 ▂▁▂▃▁▃▃▇ F1.0 12
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.10.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• 1 Inte alls villig: 1
• 2: 2
• 3: 3
• 4: 4
• 5: 5
• 6: 6
• 7 Mycket villig: 7

### 3.1.11 S3_7_1_2

Hur villig är du att acceptera och följa beslutet att inte förbjuda tiggeri?

#### 3.1.11.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

523 missings.

#### 3.1.11.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss
S3_7_1_2 Hur villig är du att acceptera och följa beslutet att inte förbjuda tiggeri? numeric 1. 1 Inte alls villig,
2. 2,
3. 3,
4. 4,
5. 5,
6. 6,
7. 7 Mycket villig
523 496 1019 5.14 2.01 1 4 6 7 7 ▂▁▁▃▁▂▃▇ F1.0
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.11.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• 1 Inte alls villig: 1
• 2: 2
• 3: 3
• 4: 4
• 5: 5
• 6: 6
• 7 Mycket villig: 7

### 3.1.12 S3_8_1_1

När det gäller att följa eller motarbeta beslutet att förbjuda tiggeri, var på skalan skulle du placera dig?

#### 3.1.12.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

496 missings.

#### 3.1.12.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss display_width
S3_8_1_1 När det gäller att följa eller motarbeta beslutet att förbjuda tiggeri, var på skalan skulle du placera dig? numeric 1. 1 Kommer absolut att motarbeta beslutet,
2. 2,
3. 3,
4. 4,
5. 5,
6. 6,
7. 7 Kommer absolut att följa beslutet
496 523 1019 5.18 1.85 1 4 6 7 7 ▁▁▂▃▁▂▃▇ F1.0 12
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.12.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• 1 Kommer absolut att motarbeta beslutet: 1
• 2: 2
• 3: 3
• 4: 4
• 5: 5
• 6: 6
• 7 Kommer absolut att följa beslutet: 7

### 3.1.13 S3_8_1_2

När det gäller att följa eller motarbeta beslutet att inte förbjuda tiggeri, var på skalan skulle du placera dig?

#### 3.1.13.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

523 missings.

#### 3.1.13.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss
S3_8_1_2 När det gäller att följa eller motarbeta beslutet att inte förbjuda tiggeri, var på skalan skulle du placera dig? numeric 1. 1 Kommer absolut att motarbeta beslutet,
2. 2,
3. 3,
4. 4,
5. 5,
6. 6,
7. 7 Kommer absolut att följa beslutet
523 496 1019 5.09 1.87 1 4 5 7 7 ▁▁▂▅▁▂▃▇ F1.0
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.13.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• 1 Kommer absolut att motarbeta beslutet: 1
• 2: 2
• 3: 3
• 4: 4
• 5: 5
• 6: 6
• 7 Kommer absolut att följa beslutet: 7

### 3.1.14 Studie3sel

Manipulation

#### 3.1.14.1 Distribution

``````show_missings <- FALSE
if (has_label(item)) {
missings <- item[is.na(haven::zap_missing(item))]
attributes(missings) <- attributes(item)
if (!is.null(attributes(item)\$labels)) {
attributes(missings)\$labels <- attributes(missings)\$labels[is.na(attributes(missings)\$labels)]
attributes(item)\$labels <- attributes(item)\$labels[!is.na(attributes(item)\$labels)]
}
if (is.numeric(item)) {
show_missings <- length(unique(haven::na_tag(missings))) > 1
item <- haven::zap_missing(item)
}
if (length(item_attributes\$labels) == 0 && is.numeric(item)) {
item <- haven::zap_labels(item)
}
}
item_nomiss <- item[!is.na(item)]

# unnest mc_multiple and so on
if (
is.character(item_nomiss) &&
stringr::str_detect(item_nomiss, stringr::fixed(", ")) &&
(exists("type", item_info) &&
stringr::str_detect(item_info\$type, pattern = stringr::fixed("multiple")))
) {
item_nomiss <- unlist(stringr::str_split(item_nomiss, pattern = stringr::fixed(", ")))
}
attributes(item_nomiss) <- attributes(item)

old_height <- knitr::opts_chunk\$get("fig.height")
non_missing_choices <- item_attributes[["labels"]]
many_labels <- length(non_missing_choices) > 7
go_vertical <- !is.numeric(item_nomiss) || many_labels
if ( go_vertical ) {
# numeric items are plotted horizontally (because that's what usually expected)
# categorical items are plotted vertically because we can use the screen real estate better this way

if (is.null(choices) ||
dplyr::n_distinct(item_nomiss) > length(non_missing_choices)) {
non_missing_choices <- unique(item_nomiss)
names(non_missing_choices) <- non_missing_choices
}
choice_multiplier <- old_height/6.5
new_height <- 2 + choice_multiplier * length(non_missing_choices)
new_height <- ifelse(new_height > 20, 20, new_height)
new_height <- ifelse(new_height < 1, 1, new_height)
knitr::opts_chunk\$set(fig.height = new_height)
}

wrap_at <- knitr::opts_chunk\$get("fig.width") * 10``````
``````# todo: if there are free-text choices mingled in with the pre-defined ones, don't show
# todo: show rare items if they are pre-defined
# todo: bin rare responses into "other category"
if (!length(item_nomiss)) {
cat("No non-missing values to show.")
} else if (is.numeric(item_nomiss) || dplyr::n_distinct(item_nomiss) < 20) {
plot_labelled(item_nomiss, item_name, wrap_at, go_vertical)
} else {
cat(dplyr::n_distinct(item_nomiss), " unique, categorical values, so not shown.")
}``````

``knitr::opts_chunk\$set(fig.height = old_height)``

0 missings.

#### 3.1.14.2 Summary statistics

``````attributes(item) <- item_attributes
df = data.frame(item, stringsAsFactors = FALSE)
names(df) = html_item_name
escaped_table(codebook_table(df))``````
name label data_type value_labels missing complete n mean sd p0 p25 p50 p75 p100 hist format.spss display_width
Studie3sel Manipulation numeric 1. förbjuda tiggeri, beslutet är fel,
2. förbjuda tiggeri, beslutet är fel, men man inte alltid kan få som man vill i en demokrati,
3. förbjuda tiggeri,
4. inte förbjuda tiggeri, beslutet är fel,
5. inte förbjuda tiggeri, beslutet är fel, men man inte alltid kan få som man vill i en demokrati,
6. inte förbjuda tiggeri
0 1019 1019 3.44 1.71 1 2 3 5 6 ▇▇▁▇▇▁▇▇ F1.0 12
``````if (show_missings) {
plot_labelled(missings, item_name, wrap_at)
}``````
``````if (!is.null(item_info)) {
# don't show choices again, if they're basically same thing as value labels
if (!is.null(choices) && !is.null(item_info\$choices) &&
all(names(na.omit(choices)) == item_info\$choices) &&
all(na.omit(choices) == names(item_info\$choices))) {
item_info\$choices <- NULL
}
item_info\$label_parsed <-
item_info\$choice_list <- item_info\$study_id <- item_info\$id <- NULL
pander::pander(item_info)
}``````

#### 3.1.14.3 Value labels

``````if (!is.null(choices) && length(choices) && length(choices) < 30) {
pander::pander(as.list(choices))
}``````
• förbjuda tiggeri, beslutet är fel: 1
• förbjuda tiggeri, beslutet är fel, men man inte alltid kan få som man vill i en demokrati: 2
• förbjuda tiggeri: 3
• inte förbjuda tiggeri, beslutet är fel: 4
• inte förbjuda tiggeri, beslutet är fel, men man inte alltid kan få som man vill i en demokrati: 5
• inte förbjuda tiggeri: 6
``missingness_report``

## 3.2 Missingness report

Among those who finished the survey. Only variables that have missings are shown.

``````if (  exists("ended", results) &&
exists("expired", results)) {
finisher_results <- dplyr::filter(results, !is.na(.data\$ended))
} else {
finisher_results <- results
warning("Could not figure out who finished the surveys, because the ",
"variables expired and ended were missing.")
}``````
``````## Warning: Could not figure out who finished the surveys, because the
## variables expired and ended were missing.``````
``````if (length(md_pattern)) {
pander::pander(md_pattern)
}``````
Table continues below
description Q64 S3_4_1_1 S3_6_1_1 S3_7_1_1 S3_8_1_1
Missings per variable 4 496 496 496 496
Missings in 4 variables 1 1 1 1 1
Missings in 4 variables 1 0 0 0 0
2 other, less frequent patterns 0 1 1 1 1
S3_4_1_2 S3_6_1_2 S3_7_1_2 S3_8_1_2 var_miss n_miss
523 523 523 523 4080 4080
0 0 0 0 4 522
1 1 1 1 4 493
1 1 1 1 10 4
``items``

## 3.3 Codebook table

``export_table(metadata_table)``
``jsonld``