Load libraries
# install.packages("tidyverse")
library(tidyverse)
library(jtools) # for theme_apa in figures
Load data
raw_data <- read_csv("survey.csv")
Clean data
Compute scale items
# Friendship satisfaction
scales_data <- raw_data %>%
mutate(id = row_number()) %>%
group_by(id) %>%
mutate(FriendSatis = sum(FriendSatis1_1, FriendSatis1_2, FriendSatis1_3, FriendSatis1_4, FriendSatis1_5, FriendSatis1_6, FriendSatis1_7, na.rm=T)/7)
Recode relationship status using labels
scales_data <- scales_data %>%
mutate(RelStatus = ifelse(RelStatus == 5, "Single", "In Relatioship"))
Select desired columns
clean_data <- scales_data %>%
select(id, age, ethnicity, ethnicity_other, gender, gender_other, CloseFriends, CloseFriendsBefore, RelStatus, RelStatus_Other, DesireRel, DesireFriends, FriendSatis) %>%
filter(!is.na(CloseFriends)) # take out empty rows
Descriptives
Create tables
# relationship status
clean_data %>%
group_by(gender) %>%
count(RelStatus)
## # A tibble: 7 x 3
## # Groups: gender [4]
## gender RelStatus n
## <chr> <chr> <int>
## 1 Female In Relatioship 21
## 2 Female Single 45
## 3 Male In Relatioship 16
## 4 Male Single 33
## 5 Non-binary In Relatioship 2
## 6 Non-binary Single 2
## 7 Other Single 1
# friendship number
clean_data %>%
group_by(gender) %>%
dplyr::summarise(meanFriends = mean(CloseFriends, na.rm=T))
## # A tibble: 4 x 2
## gender meanFriends
## * <chr> <dbl>
## 1 Female 5.91
## 2 Male 6.47
## 3 Non-binary 3.75
## 4 Other 7
clean_data %>%
group_by(gender) %>%
dplyr::summarise(meanFriendsBefore = mean(CloseFriendsBefore, na.rm=T))
## # A tibble: 4 x 2
## gender meanFriendsBefore
## * <chr> <dbl>
## 1 Female 6.94
## 2 Male 5.53
## 3 Non-binary 4
## 4 Other 7
Visualizations
# rel status overall
ggplot(clean_data, aes(x = RelStatus)) +
geom_bar() +
theme_apa()

# by gender
ggplot(clean_data, aes(x = RelStatus)) +
facet_grid(~gender) +
geom_bar() +
theme_apa()

Data analysis
# RESEARCH QUESTION 1:
# Do people with more friends have greater friendship satisfaction?
lm(data = clean_data, FriendSatis ~ CloseFriends) %>% summary()
##
## Call:
## lm(formula = FriendSatis ~ CloseFriends, data = clean_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.7661 -0.4084 0.1614 0.7395 1.3723
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.55739 0.17483 43.23 < 2e-16 ***
## CloseFriends 0.07031 0.02450 2.87 0.00486 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.005 on 118 degrees of freedom
## Multiple R-squared: 0.06526, Adjusted R-squared: 0.05734
## F-statistic: 8.239 on 1 and 118 DF, p-value: 0.004861
# RESEARCH QUESTION 2:
# do people with more friends (quantity) have less desire for a romantic relationship?
lm(data = clean_data, DesireRel ~ CloseFriends) %>% summary()
##
## Call:
## lm(formula = DesireRel ~ CloseFriends, data = clean_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.7805 -0.7423 0.2450 0.3722 1.4358
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.81866 0.23104 16.528 <2e-16 ***
## CloseFriends -0.01273 0.03190 -0.399 0.691
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.11 on 79 degrees of freedom
## (39 observations deleted due to missingness)
## Multiple R-squared: 0.00201, Adjusted R-squared: -0.01062
## F-statistic: 0.1591 on 1 and 79 DF, p-value: 0.6911
# do people who have higher friendship satisfaction (quality) have less desire for a romantic relationship?
lm(data = clean_data, DesireRel ~ FriendSatis) %>% summary()
##
## Call:
## lm(formula = DesireRel ~ FriendSatis, data = clean_data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.8466 -0.7260 0.2287 0.4247 1.6659
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.8969 0.9851 2.941 0.0043 **
## FriendSatis 0.1055 0.1222 0.863 0.3906
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.106 on 79 degrees of freedom
## (39 observations deleted due to missingness)
## Multiple R-squared: 0.009346, Adjusted R-squared: -0.003194
## F-statistic: 0.7453 on 1 and 79 DF, p-value: 0.3906
Visualize results above
# RESEARCH QUESTION 1:
# Do people with more friends have greater friendship satisfaction?
ggplot(clean_data, aes(x = CloseFriends, y = FriendSatis)) +
geom_point() +
geom_smooth(method="lm") +
theme_apa()

# RESEARCH QUESTION 2:
# do people with more friends (quantity) have less desire for a romantic relationship?
ggplot(clean_data, aes(x = CloseFriends, y = DesireRel)) +
geom_point() +
geom_smooth(method="lm") +
theme_apa()

# do people who have higher friendship satisfaction (quality) have less desire for a romantic relationship?
ggplot(clean_data, aes(x = FriendSatis, y = DesireRel)) +
geom_point() +
geom_smooth(method="lm") +
theme_apa()
