Import some packages.
library(flextable)
library(tidyverse)
library(broom)Copy over the table formatting function.
# turn dataframe into html table
formatAsTable <- function(data) {
data %>%
mutate(across(where(is.double), ~ round(., 3))) %>%
flextable %>%
color(color = "white", part = "all")
}Import the data and look at the top three rows.
chks <- read_csv(file.path("..", "data", "clean-data.csv")) %>%
select(c(interdep, disclose, intcheck, discheck))
chks %>%
head(3) %>%
formatAsTable %>%
autofitinterdep | disclose | intcheck | discheck |
FALSE | FALSE | Neither agree nor disagree | Strongly disagree |
TRUE | TRUE | Somewhat agree | Strongly agree |
TRUE | TRUE | Somewhat disagree | Neither agree nor disagree |
Clean up data for the analyses.
scale_order <- c("Strongly agree",
"Somewhat agree",
"Neither agree nor disagree",
"Somewhat disagree",
"Strongly disagree")
scale_key <- 5:1 %>%
set_names(scale_order)
chks <- chks %>%
mutate(across(ends_with("check"),
~ factor(., scale_order, ordered = T),
.names = "{col}.f")) %>%
mutate(across(ends_with("check"),
~ recode(., !!!scale_key))) %>%
mutate(discor = ifelse(disclose == 0,
discheck < 3,
discheck > 3),
intcor = ifelse(interdep == 0,
intcheck < 3,
intcheck > 3)) %>%
mutate(correct = discor & intcor) %>%
filter(!is.na(intcheck))How many respondents clicked each scale option in each condition?
chks %>%
count(interdep, intcheck.f) %>%
arrange(interdep, desc(intcheck.f)) %>%
formatAsTable %>%
autofit %>%
bg(bg = "#074005",
i = ~ ifelse(interdep == 0,
scale_key[intcheck.f] < 3,
scale_key[intcheck.f] > 3))interdep | intcheck.f | n |
FALSE | Strongly disagree | 133 |
FALSE | Somewhat disagree | 35 |
FALSE | Neither agree nor disagree | 24 |
FALSE | Somewhat agree | 20 |
FALSE | Strongly agree | 10 |
TRUE | Strongly disagree | 3 |
TRUE | Somewhat disagree | 8 |
TRUE | Neither agree nor disagree | 21 |
TRUE | Somewhat agree | 77 |
TRUE | Strongly agree | 113 |
chks %>%
count(disclose, discheck.f) %>%
arrange(disclose, desc(discheck.f)) %>%
formatAsTable %>%
autofit %>%
bg(bg = "#074005",
i = ~ ifelse(disclose == 0,
scale_key[discheck.f] < 3,
scale_key[discheck.f] > 3))disclose | discheck.f | n |
FALSE | Strongly disagree | 197 |
FALSE | Somewhat disagree | 10 |
FALSE | Neither agree nor disagree | 4 |
FALSE | Somewhat agree | 7 |
FALSE | Strongly agree | 4 |
TRUE | Somewhat disagree | 2 |
TRUE | Neither agree nor disagree | 4 |
TRUE | Somewhat agree | 17 |
TRUE | Strongly agree | 199 |
Exactly 355 of 444 participants, or 80%, responded to both manipulation checks correctly.
Is there a significant relationship between the manipulation and the manipulation checks?
intfit <- lm(intcheck ~ interdep, chks)
tidy(intfit) %>%
formatAsTableterm | estimate | std.error | statistic | p.value |
(Intercept) | 1.824 | 0.071 | 25.739 | 0 |
interdepTRUE | 2.477 | 0.100 | 24.717 | 0 |
disfit <- lm(discheck ~ disclose, chks)
tidy(disfit) %>%
formatAsTableterm | estimate | std.error | statistic | p.value |
(Intercept) | 1.248 | 0.044 | 28.655 | 0 |
discloseTRUE | 3.613 | 0.062 | 58.666 | 0 |
Output document:
options(knitr.duplicate.label = "allow")
rmarkdown::render("manipulations.Rmd",
output_dir = file.path("..", "github", "thesis"))