Import some packages.
library(flextable)
library(tidyverse)
library(broom)
Copy over the table formatting function.
# turn dataframe into html table
<- function(data) {
formatAsTable %>%
data mutate(across(where(is.double), ~ round(., 3))) %>%
%>%
flextable color(color = "white", part = "all")
}
Import the data and look at the top three rows.
<- read_csv(file.path("..", "data", "check-pilot.csv"))
chks
%>%
chks head(3) %>%
%>%
formatAsTable autofit
interdep | disclose | intcheck | discheck |
0 | 0 | Strongly agree | Strongly agree |
0 | 1 | Neither agree nor disagree | Somewhat agree |
0 | 0 | Somewhat agree | Neither agree nor disagree |
Clean up data for the analyses.
<- c("Strongly agree",
scale_order "Somewhat agree",
"Neither agree nor disagree",
"Somewhat disagree",
"Strongly disagree")
<- 5:1 %>%
scale_key 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)))
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,
< 3,
scale_key[intcheck.f] > 3)) scale_key[intcheck.f]
interdep | intcheck.f | n |
0 | Neither agree nor disagree | 2 |
0 | Somewhat agree | 2 |
0 | Strongly agree | 1 |
1 | Neither agree nor disagree | 1 |
1 | Somewhat agree | 4 |
%>%
chks count(disclose, discheck.f) %>%
arrange(disclose, desc(discheck.f)) %>%
%>%
formatAsTable %>%
autofit bg(bg = "#074005",
i = ~ ifelse(disclose == 0,
< 3,
scale_key[discheck.f] > 3)) scale_key[discheck.f]
disclose | discheck.f | n |
0 | Somewhat disagree | 1 |
0 | Neither agree nor disagree | 1 |
0 | Somewhat agree | 2 |
0 | Strongly agree | 1 |
1 | Neither agree nor disagree | 1 |
1 | Somewhat agree | 3 |
1 | Strongly agree | 1 |
Is there a significant relationship between the manipulation and the manipulation checks?
<- lm(intcheck ~ interdep, chks)
intfit tidy(intfit) %>%
formatAsTable
term | estimate | std.error | statistic | p.value |
(Intercept) | 3.8 | 0.300 | 12.667 | 0 |
interdep | 0.0 | 0.424 | 0.000 | 1 |
<- lm(discheck ~ disclose, chks)
disfit tidy(disfit) %>%
formatAsTable
term | estimate | std.error | statistic | p.value |
(Intercept) | 3.6 | 0.424 | 8.485 | 0.000 |
disclose | 0.4 | 0.600 | 0.667 | 0.524 |
Output document:
options(knitr.duplicate.label = "allow")
::render("check-pilot.Rmd", output_dir = file.path("..", "github", "thesis")) rmarkdown