#Loading packages
# Install pacman only if needed
if (!require("pacman")) install.packages("pacman")
## Loading required package: pacman
## Warning: package 'pacman' was built under R version 4.5.3
# Load packages used for organization and visualization
pacman::p_load(
tidyverse,
ggplot2
)
tuenti_items <- tibble(
construct = c(
"Socializing", "Socializing", "Socializing", "Socializing",
"Self esteem", "Self esteem", "Self esteem", "Self esteem",
"Loneliness", "Loneliness", "Loneliness",
"Wellbeing", "Wellbeing", "Wellbeing",
"Tuenti use"
),
item = c(
"Contact with friends",
"Talk to friends living far away",
"Meet and talk to friends from the past",
"Friends show interest",
"Deserve to be appreciated",
"Belief in personal virtues",
"Capable of doing things",
"Positive attitude toward self",
"Feeling lonely",
"Having no company",
"Feeling isolated",
"Life close to personal ideal",
"Conditions of life",
"Life satisfaction",
"Time spent daily using Tuenti"
),
mean = c(
3.35, 3.66, 3.32, 3.24,
3.37, 3.43, 3.44, 3.33,
1.39, 1.32, 1.26,
4.41, 4.89, 5.13,
2.18
),
sd = c(
.76, .71, .67, .89,
.69, .61, .64, .68,
.65, .56, .53,
1.17, 1.11, 1.09,
1.30
)
)
#Summarize item means by construct
construct_summary <- tuenti_items %>%
group_by(construct) %>%
summarise(
number_of_items = n(),
average_item_mean = mean(mean),
average_item_sd = mean(sd),
.groups = "drop"
)
print(construct_summary)
## # A tibble: 5 × 4
## construct number_of_items average_item_mean average_item_sd
## <chr> <int> <dbl> <dbl>
## 1 Loneliness 3 1.32 0.58
## 2 Self esteem 4 3.39 0.655
## 3 Socializing 4 3.39 0.758
## 4 Tuenti use 1 2.18 1.3
## 5 Wellbeing 3 4.81 1.12
figure_1 <- ggplot(tuenti_items, aes(x = reorder(item, mean), y = mean)) +
geom_col() +
coord_flip() +
labs(
title = "Reported Item Means from the Tuenti Social Media Study",
subtitle = "Data organized from Apaolaza et al. (2013)",
x = "Survey item",
y = "Reported mean"
)
print(figure_1)
ggsave(
filename = "figure_1_reported_item_means.png",
plot = figure_1,
width = 10,
height = 7,
dpi = 300
)
figure_2 <- ggplot(construct_summary, aes(x = reorder(construct, average_item_mean), y = average_item_mean)) +
geom_col() +
coord_flip() +
labs(
title = "Average Reported Item Mean by Construct",
subtitle = "Construct summaries based on Apaolaza et al. (2013), Table 1",
x = "Construct",
y = "Average reported item mean"
)
print(figure_2)
ggsave(
filename = "figure_2_average_construct_means.png",
plot = figure_2,
width = 8,
height = 5,
dpi = 300
)
#reported standardized regression coefficients
path_coefficients <- tibble(
relationship = c(
"Tuenti use to socializing",
"Socializing to self esteem",
"Socializing to loneliness",
"Self esteem to wellbeing",
"Loneliness to wellbeing"
),
coefficient = c(
.30,
.22,
-.24,
.47,
-.27
)
)
print(path_coefficients)
## # A tibble: 5 × 2
## relationship coefficient
## <chr> <dbl>
## 1 Tuenti use to socializing 0.3
## 2 Socializing to self esteem 0.22
## 3 Socializing to loneliness -0.24
## 4 Self esteem to wellbeing 0.47
## 5 Loneliness to wellbeing -0.27
#Figure 3: Corrected path coefficients
figure_3 <- ggplot(path_coefficients, aes(x = reorder(relationship, coefficient), y = coefficient)) +
geom_col() +
geom_hline(yintercept = 0) +
coord_flip() +
labs(
title = "Reported Relationships in the Tuenti Social Media Study",
subtitle = "Standardized regression coefficients from Apaolaza et al. (2013)",
x = "Relationship",
y = "Standardized regression coefficient"
)
print(figure_3)
ggsave(
filename = "figure_3_path_coefficients_corrected.png",
plot = figure_3,
width = 10,
height = 6,
dpi = 300
)
#Exporting cleaned summary tables
write_csv(tuenti_items, "tuenti_reported_item_data.csv")
write_csv(construct_summary, "tuenti_construct_summary.csv")
write_csv(path_coefficients, "tuenti_path_coefficients_corrected.csv")