-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplots_graphs_tables.R
More file actions
221 lines (197 loc) · 9.36 KB
/
Copy pathplots_graphs_tables.R
File metadata and controls
221 lines (197 loc) · 9.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
## This script is to create APA style plots, graphs, and tables for the manuscript
# Correlation Tables -----------------------------------------------------------
#Installing the apaTables package to create apa style tables
install.packages("apaTables")
# Loading the apaTables package
library(apaTables)
# Creating APA style tables for the correlational analyses
# For numerical outcome variables
apa.cor.table(data[c("LingObf", "CertSent", "Refs")],
filename = "num_outcomes_corr_table.doc",
table.number = 4)
# For subcomponents of abstraction
apa.cor.table(data[,c("article", "prep", "quantity")],
filename = "abs_subcomponents_corr_table.doc",
table.number = 2)
# For subcomponents of obfuscation
apa.cor.table(data[,c("cause", "abstraction", "jargon", "emo_pos", "flesch_re")],
filename = "obf_subcomponents_corr_table.doc",
table.number = 3)
# Plots -----------------------------------------------------------------------
# Installing packages
install.packages("tidyverse")
install.packages("jtools")
install.packages("psych")
# Loading packages
library(tidyverse)
library(jtools)
library(psych)
# Creating groups of PaperType and Fraudulent or Genuine (including the data
# without the outlier for LingObf so that we can plot that as well)
groups_pt <- group_by(data, PaperType)
groups_fg <- group_by(data, Genuine_or_Fraudulent)
groups_sm <- group_by(data, S_or_M)
# Calculating 95% confidence intervals for the groups on each outcome variable
CIs_groups_pt_ref <- summarise(groups_pt,
mean = mean(Refs, na.rm = TRUE),
sd = sd(Refs, na.rm = TRUE),
n = n(),
CI_upper = mean + 1.96*sd/sqrt(n),
CI_lower = mean - 1.96*sd/sqrt(n))
CIs_groups_fg_ref <- summarise(groups_fg,
mean = mean(Refs, na.rm = TRUE),
sd = sd(Refs, na.rm = TRUE),
n = n(),
CI_upper = mean + 1.96*sd/sqrt(n),
CI_lower = mean - 1.96*sd/sqrt(n))
CIs_groups_pt_obf <- summarise(groups_pt,
mean = mean(LingObf, na.rm = TRUE),
sd = sd(LingObf, na.rm = TRUE),
n = n(),
CI_upper = mean + 1.96*sd/sqrt(n),
CI_lower = mean - 1.96*sd/sqrt(n),
ymin = min(LingObf),
ymax = max(LingObf))
CIs_groups_fg_obf <- summarise(groups_fg,
mean = mean(LingObf, na.rm = TRUE),
sd = sd(LingObf, na.rm = TRUE),
n = n(),
CI_upper = mean + 1.96*sd/sqrt(n),
CI_lower = mean - 1.96*sd/sqrt(n),
ymin = min(LingObf),
ymax = max(LingObf))
CIs_groups_pt_cert <- summarise(groups_pt,
mean = mean(CertSent, na.rm = TRUE),
sd = sd(CertSent, na.rm = TRUE),
n = n(),
CI_upper = mean + 1.96*sd/sqrt(n),
CI_lower = mean - 1.96*sd/sqrt(n),
ymin = min(CertSent),
ymax = max(CertSent))
CIs_groups_fg_cert <- summarise(groups_fg,
mean = mean(CertSent, na.rm = TRUE),
sd = sd(CertSent, na.rm = TRUE),
n = n(),
CI_upper = mean + 1.96*sd/sqrt(n),
CI_lower = mean - 1.96*sd/sqrt(n),
ymin = min(CertSent),
ymax = max(CertSent))
CIs_groups_sm_obf <- summarise(groups_sm,
mean = mean(LingObf, na.rm = TRUE),
sd = sd(LingObf, na.rm = TRUE),
n = n(),
CI_upper = mean + 1.96*sd/sqrt(n),
CI_lower = mean - 1.96*sd/sqrt(n))
# Plots for References ---------------------------------------------------------
# Bar chart for references within PaperType groups (with 95% confidence intervals)
# Statistics to see what the scales need to be
CIs_groups_pt_ref
# Creating the bar plot
CIs_groups_pt_ref %>% ggplot(aes(factor(PaperType), mean)) +
geom_bar(stat = "identity", fill = "grey", color = "black") +
xlab('Paper Type') +
ylab('References') +
theme_apa() +
geom_errorbar(aes(ymin = CI_lower, ymax = CI_upper), width = .2) +
theme(axis.title.y = element_text(face = "bold")) +
theme(axis.title.x = element_text(face = "bold")) +
scale_y_continuous(breaks = c(0, 10, 20, 30, 40, 50, 60, 70),
expand = c(0,0),
limits = c(0, 70))
# Bar chart for references within G or F groups (with 95% confidence intervals)
# Statistics to see what the scales need to be
CIs_groups_fg_ref
# Creating the bar plot
CIs_groups_fg_ref %>% ggplot(aes(factor(Genuine_or_Fraudulent), mean)) +
geom_bar(stat = "identity", fill = "grey", color = "black") +
xlab('Fraudulent or Genuine Papers') +
ylab('References') +
theme_apa() +
geom_errorbar(aes(ymin = CI_lower, ymax = CI_upper), width = .2) +
theme(axis.title.y = element_text(face = "bold")) +
theme(axis.title.x = element_text(face = "bold")) +
scale_y_continuous(breaks = c(0, 10, 20, 30, 40, 50, 60, 70),
expand = c(0,0),
limits = c(0, 70))
# Plots for Linguistic Obfuscation ----------------------------------------
# Plots for means of LingObf within PaperType groups (with 95% confidence intervals)
# Statistics to see what the scales need to be
CIs_groups_pt_obf
# Creating the plot for LingObf
CIs_groups_pt_obf %>%
ggplot(aes(x = factor(PaperType), y = mean)) +
geom_point(shape = 21, fill = "grey", size = 3) +
geom_errorbar(aes(ymin = CI_lower, ymax = CI_upper), width = 0.2, color = "black") +
xlab('Paper Type') +
ylab('Linguistic Obfuscation') +
theme_apa() +
theme(axis.title.y = element_text(face = "bold"),
axis.title.x = element_text(face = "bold")) +
scale_y_continuous(breaks = seq(-2, 1.5, 0.5),
expand = c(0,0),
limits = c(-2, 1.5))
# Plot for means of LingObf within G or F groups (with 95% confidence intervals)
# Statistics to see what the scales need to be
CIs_groups_fg_obf
# Plot for means of LingObf within F or G group
CIs_groups_fg_obf %>%
ggplot(aes(x = factor(Genuine_or_Fraudulent), y = mean)) +
geom_point(shape = 21, fill = "grey", size = 3) +
geom_errorbar(aes(ymin = CI_lower, ymax = CI_upper), width = 0.2, color = "black") +
xlab('Paper Type') +
ylab('Linguistic Obfuscation') +
theme_apa() +
theme(axis.title.y = element_text(face = "bold"),
axis.title.x = element_text(face = "bold")) +
scale_y_continuous(breaks = seq(-1.25, 1.25, 0.25),
expand = c(0,0),
limits = c(-1.25, 1.25))
# Plots for Certainty Sentiment -------------------------------------------
# Plot for CerSent within PaperType groups (with 95% confidence interval)
# Stats to determine scales
CIs_groups_pt_cert
# Plot for means of CertSent within PaperType groups (with 95% confidence interval)
CIs_groups_pt_cert %>%
ggplot(aes(x = factor(PaperType), y = mean)) +
geom_point(shape = 21, fill = "grey", size = 3) +
geom_errorbar(aes(ymin = CI_lower, ymax = CI_upper), width = 0.2, color = "black") +
xlab('Paper Type') +
ylab('Certainty Sentiment') +
theme_apa() +
theme(axis.title.y = element_text(face = "bold"),
axis.title.x = element_text(face = "bold")) +
scale_y_continuous(breaks = seq(5.9, 6.4, .1),
expand = c(0,0),
limits = c(5.9, 6.4))
# Plot for CertSent within Fraudulent or Genuine Groups (with 95% confidence intervals)
#Stats to determine scales
CIs_groups_fg_cert
# Plot for CertSent within Fraudulent or Genuine Groups
CIs_groups_fg_cert %>%
ggplot(aes(x = factor(Genuine_or_Fraudulent), y = mean)) +
geom_point(shape = 21, fill = "grey", size = 3) +
geom_errorbar(aes(ymin = CI_lower, ymax = CI_upper), width = 0.2, color = "black") +
xlab('Fraudulent or Genuine Papers') +
ylab('Certainty Sentiment') +
theme_apa() +
theme(axis.title.y = element_text(face = "bold"),
axis.title.x = element_text(face = "bold")) +
scale_y_continuous(breaks = seq(5.9, 6.4, .1),
expand = c(0,0),
limits = c(5.9, 6.4))
# Plot for follow up analysis of single- and multi-author groups on obfuscation
# Statistics
CIs_groups_sm_obf
# Plotting the means
CIs_groups_sm_obf %>%
ggplot(aes(x = factor(S_or_M), y = mean)) +
geom_point(shape = 21, fill = "grey", size = 3) +
geom_errorbar(aes(ymin = CI_lower, ymax = CI_upper), width = 0.2, color = "black") +
xlab('Author Number Group') +
ylab('Linguistic Obfuscation') +
theme_apa() +
theme(axis.title.y = element_text(face = "bold"),
axis.title.x = element_text(face = "bold")) +
scale_y_continuous(breaks = seq(-1.25, 1.25, 0.25),
expand = c(0,0),
limits = c(-1.25, 1.25))