This script contains pre-processing and scoring of the CES-D, UCLA, LSAS and TRIM questionnaires related to participants who took part in our study.
First, we load packages we need for analyses
#PACKAGES
library (tidyverse) #for data handling
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 0.3.5
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.4.1
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(readxl) #to read excel files
library(writexl) #to export data as excel file
## Warning: il pacchetto 'writexl' è stato creato con R versione 4.2.3
Then, we proceed with the scoring of the questionnaires
#CES-D It is a self-report scale useful to evaluate the level of depression in the general population. It includes 20 items featuring some symptoms. Participants are asked to rate the frequency of occurrence of the listed behaviors using a 4-point Likert scale ranging from 0=not at all or rarely, to 4=in most of the days or every day.
We start by loading the dataset containing ratings of our sample in the questionnaire
#import file
cesd <- read_excel("Surveys_JPPS2.xlsx", 3) #import file
cesd <- cesd[-1,] #remove first line
#is.na(cesd) #check for na values
Now we recode values of the items n. 4, 8, 12, 16, which need of an inverse recoding
cesd <-
cesd %>%
dplyr::mutate(item_4= case_when(item_4 == "0" ~ "3",
item_4 == "1" ~ "2",
item_4 == "2" ~ "1",
item_4 == "3" ~ "0"
)) #recode value
cesd <-
cesd %>%
dplyr::mutate(item_8= case_when(item_8 == "0" ~ "3",
item_8 == "1" ~ "2",
item_8 == "2" ~ "1",
item_8 == "3" ~ "0"
)) #recode value
cesd <-
cesd %>%
dplyr::mutate(item_12= case_when(item_12 == "0" ~ "3",
item_12 == "1" ~ "2",
item_12 == "2" ~ "1",
item_12 == "3" ~ "0"
)) #recode value
cesd <-
cesd %>%
dplyr::mutate(item_16= case_when(item_16 == "0" ~ "3",
item_16 == "1" ~ "2",
item_16 == "2" ~ "1",
item_16 == "3" ~ "0"
)) #recode value
A brief check to the new dataset
cesd
## # A tibble: 26 × 24
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 14 26 1 6 0 1 1 1 2 2 2
## 2 7 28 2 4 0 2 0 1 2 1 1
## 3 15 23 1 6 1 0 1 1 2 1 1
## 4 18 25 1 7 1 1 1 0 1 1 0
## 5 25 27 2 7 0 0 0 0 0 0 1
## 6 2 32 2 9 1 1 1 1 2 1 1
## 7 8 25 2 7 2 1 1 2 1 1 0
## 8 11 26 2 6 2 1 2 0 2 0 1
## 9 102 26 1 7 0 0 0 0 1 0 0
## 10 22 29 2 8 2 0 3 3 3 3 3
## # … with 16 more rows, 13 more variables: item_8 <chr>, item_9 <chr>,
## # item_10 <chr>, item_11 <chr>, item_12 <chr>, item_13 <chr>, item_14 <chr>,
## # item_15 <chr>, item_16 <chr>, item_17 <chr>, item_18 <chr>, item_19 <chr>,
## # item_20 <chr>, and abbreviated variable names ¹`Subject Number`,
## # ²EducationLevel
#is.na(cesd) #check for na values
Before doing the scoring, we convert rating scores into numeric (now they are in character format)
cesd <-
cesd %>%
dplyr::mutate_at(vars(item_1:item_20), as.numeric)
We calculate the sum of the scores each participant reported in the questionnaire
sum <-
cesd %>%
dplyr::select(item_1:item_20)
cesd$sum <- rowSums(sum, na.rm=TRUE)
We finally export the dataset as an excel file
# save path
savepath <- "/Users/Giovy/Downloads/Progetti Attivi/Joint_PPS/Pt2/Respondent/cesd_scoring.xlsx"
# save to excel
write_xlsx(cesd, savepath, col_names = TRUE)
##scoring criteria Sum of scores ranges between 0 and 60. score until 15: no clinical score score ranging between 16 and 22: participant has mild depression score of or upon 23: participant presents clinical depression
The total sample is composed by 26 participants.
cesd %>%
dplyr::filter(sum <= 15) %>%
count() #count n of participants with score <=15
## # A tibble: 1 × 1
## n
## <int>
## 1 8
There are 8 “normal” people
cesd %>% filter( between(sum, 16, 22) )%>%
count() #count n of participants with score between 16 and 22
## # A tibble: 1 × 1
## n
## <int>
## 1 5
There are 5 people with mild depression
cesd %>%
filter(sum >= 23) %>%
count() #count n of participants with score >=23
## # A tibble: 1 × 1
## n
## <int>
## 1 13
There are 13 people with severe depression
#UCLA The UCLA loneliness scale is a 20-item rating scale that measures the subjective experience of loneliness on a four-point Likert scale, ranging from 1=never to 4=often.
We start by loading the dataset containing ratings of our sample in the questionnaire
#import file
ucla <- read_excel("Surveys_JPPS2.xlsx", 2) #import file
ucla <- ucla[-1,] #remove first line
ucla #show
## # A tibble: 26 × 24
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 14 26 1 6 3 2 1 3 3 3 1
## 2 7 28 2 4 3 2 2 3 2 3 1
## 3 15 23 1 6 3 2 3 2 4 3 2
## 4 18 25 1 7 3 2 1 3 3 3 2
## 5 25 27 2 7 4 2 2 4 4 3 1
## 6 2 32 2 9 3 3 3 2 4 3 1
## 7 8 25 2 7 3 2 1 3 4 3 1
## 8 11 26 2 6 3 2 3 2 4 3 1
## 9 102 26 1 7 3 1 1 4 4 3 1
## 10 22 29 2 8 3 3 3 1 3 3 4
## # … with 16 more rows, 13 more variables: item_8 <chr>, item_9 <chr>,
## # item_10 <chr>, item_11 <chr>, item_12 <chr>, item_13 <chr>, item_14 <chr>,
## # item_15 <chr>, item_16 <chr>, item_17 <chr>, item_18 <chr>, item_19 <chr>,
## # item_20 <chr>, and abbreviated variable names ¹`Subject Number`,
## # ²EducationLevel
#is.na(ucla) #check for na values
Now we recode values of the items n. 1, 5, 6, 9, 10, 15, 16, 19, 20 which need of an inverse recoding
ucla <-
ucla %>%
dplyr::mutate(item_1= case_when(item_1 == "1" ~ "4",
item_1 == "2" ~ "3",
item_1 == "3" ~ "2",
item_1 == "4" ~ "1"
)) #recode value
ucla <-
ucla %>%
dplyr::mutate(item_5= case_when(item_5 == "1" ~ "4",
item_5 == "2" ~ "3",
item_5 == "3" ~ "2",
item_5 == "4" ~ "1"
)) #recode value
ucla <-
ucla %>%
dplyr::mutate(item_6= case_when(item_6 == "1" ~ "4",
item_6 == "2" ~ "3",
item_6 == "3" ~ "2",
item_6 == "4" ~ "1"
)) #recode value
ucla <-
ucla %>%
dplyr::mutate(item_9= case_when(item_9 == "1" ~ "4",
item_9 == "2" ~ "3",
item_9 == "3" ~ "2",
item_9 == "4" ~ "1"
)) #recode value
ucla <-
ucla %>%
dplyr::mutate(item_10= case_when(item_10 == "1" ~ "4",
item_10 == "2" ~ "3",
item_10 == "3" ~ "2",
item_10 == "4" ~ "1"
)) #recode value
ucla <-
ucla %>%
dplyr::mutate(item_15= case_when(item_15 == "1" ~ "4",
item_15 == "2" ~ "3",
item_15 == "3" ~ "2",
item_15 == "4" ~ "1"
)) #recode value
ucla <-
ucla %>%
dplyr::mutate(item_16= case_when(item_16 == "1" ~ "4",
item_16 == "2" ~ "3",
item_16 == "3" ~ "2",
item_16 == "4" ~ "1"
)) #recode value
ucla <-
ucla %>%
dplyr::mutate(item_19= case_when(item_19 == "1" ~ "4",
item_19 == "2" ~ "3",
item_19 == "3" ~ "2",
item_19 == "4" ~ "1"
)) #recode value
ucla <-
ucla %>%
dplyr::mutate(item_20= case_when(item_20 == "1" ~ "4",
item_20 == "2" ~ "3",
item_20 == "3" ~ "2",
item_20 == "4" ~ "1"
)) #recode value
Before doing the scoring, we convert rating scores into numeric (now they are in character format)
ucla <-
ucla %>%
dplyr::mutate_at(vars(item_1:item_20), as.numeric)
We calculate the sum of the scores each participant reported in the questionnaire
sum <-
ucla %>%
dplyr::select(item_1:item_20)
ucla$sum <- rowSums(sum, na.rm=TRUE)
We finally export the dataset as an excel file
# save path
savepath <- "/Users/Giovy/Downloads/Progetti Attivi/Joint_PPS/Pt2/Respondent/ucla_scoring.xlsx"
# save to excel
write_xlsx(ucla, savepath, col_names = TRUE)
##scoring criteria The total score ranges from 20 to 80. Higher scores indicate higher loneliness. The most commonly used categorization is the following: 20–34 denotes a low degree of loneliness, 35–49 a moderate degree of loneliness, 50–64 a moderately high degree of loneliness, and 65–80 a high degree of loneliness.
The total sample is composed by 26 participants
ucla %>% filter( between(sum, 20, 34) )%>%
count() #count n of participants with score between 20 and 34
## # A tibble: 1 × 1
## n
## <int>
## 1 6
There is 6 person with a low degree of loneliness
ucla %>% filter( between(sum, 35, 49) )%>%
count() #count n of participants with score between 35 and 49
## # A tibble: 1 × 1
## n
## <int>
## 1 15
There are 15 people with a moderate degree of loneliness
ucla %>% filter( between(sum, 50, 64) )%>%
count() #count n of participants with score between 50 and 64
## # A tibble: 1 × 1
## n
## <int>
## 1 5
There are 5 people with a moderately high degree of loneliness
ucla %>% filter( between(sum, 65, 80) )%>%
count() #count n of participants with score between 65 and 80
## # A tibble: 1 × 1
## n
## <int>
## 1 0
There are 0 people with a high degree of loneliness
#LSAS The Liebowitz Social Anxiety Scale is a self-report questionnaire contains 24 items, 13 concerning performance anxiety and 11 concerning social situations. Each item is rated separately for fear: (0 to 3 = none, mild, moderate, severe) and avoidance behavior (0 to 3 = never, occasionally, often, usually).
##LSAS_fear
We start by loading the dataset containing ratings of our sample in the questionnaire
#import file
lsas_fear <- read_excel("Surveys_JPPS2.xlsx", 4) #import file
lsas_fear <- lsas_fear[-1,] #remove first line
#is.na(lsas_fear) #check for na values
A brief check to the new dataset
lsas_fear
## # A tibble: 26 × 28
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 14 26 1 6 1 0 1 0 0 1 0
## 2 7 28 2 4 2 1 2 2 2 2 3
## 3 15 23 1 6 1 0 2 1 0 2 1
## 4 18 25 1 7 1 1 1 0 2 1 2
## 5 25 27 2 7 1 0 1 0 0 0 1
## 6 2 32 2 9 1 1 2 1 2 0 1
## 7 8 25 2 7 1 1 0 1 1 1 2
## 8 11 26 2 6 2 0 0 1 0 0 0
## 9 102 26 1 7 1 1 0 1 0 1 1
## 10 22 29 2 8 2 1 1 1 2 0 0
## # … with 16 more rows, 17 more variables: item_8 <chr>, item_9 <chr>,
## # item_10 <chr>, item_11 <chr>, item_12 <chr>, item_13 <chr>, item_14 <chr>,
## # item_15 <chr>, item_16 <chr>, item_17 <chr>, item_18 <chr>, item_19 <chr>,
## # item_20 <chr>, item_21 <chr>, item_22 <chr>, item_23 <chr>, item_24 <chr>,
## # and abbreviated variable names ¹Subject_Number, ²EducationLevel
Before doing the scoring, we convert rating scores into numeric (now they are in character format)
lsas_fear <-
lsas_fear %>%
dplyr::mutate_at(vars(item_1:item_24), as.numeric)
We calculate the sum of the scores each participant reported in the questionnaire
sum_fear <-
lsas_fear %>%
dplyr::select(item_1:item_24)
lsas_fear$sum_fear <- rowSums(sum_fear, na.rm=TRUE)
lsas_fear
## # A tibble: 26 × 29
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 14 26 1 6 1 0 1 0 0 1 0
## 2 7 28 2 4 2 1 2 2 2 2 3
## 3 15 23 1 6 1 0 2 1 0 2 1
## 4 18 25 1 7 1 1 1 0 2 1 2
## 5 25 27 2 7 1 0 1 0 0 0 1
## 6 2 32 2 9 1 1 2 1 2 0 1
## 7 8 25 2 7 1 1 0 1 1 1 2
## 8 11 26 2 6 2 0 0 1 0 0 0
## 9 102 26 1 7 1 1 0 1 0 1 1
## 10 22 29 2 8 2 1 1 1 2 0 0
## # … with 16 more rows, 18 more variables: item_8 <dbl>, item_9 <dbl>,
## # item_10 <dbl>, item_11 <dbl>, item_12 <dbl>, item_13 <dbl>, item_14 <dbl>,
## # item_15 <dbl>, item_16 <dbl>, item_17 <dbl>, item_18 <dbl>, item_19 <dbl>,
## # item_20 <dbl>, item_21 <dbl>, item_22 <dbl>, item_23 <dbl>, item_24 <dbl>,
## # sum_fear <dbl>, and abbreviated variable names ¹Subject_Number,
## # ²EducationLevel
lsas_fear <-
lsas_fear %>%
dplyr::mutate(scale = "lsas_fear", .after = "EducationLevel") #create a new column for scale
##LSAS_avoidance
We start by loading the dataset containing ratings of our sample in the questionnaire
#import file
lsas_avoidance <- read_excel("Surveys_JPPS2.xlsx", 5) #import file
lsas_avoidance <- lsas_avoidance[-1,] #remove first line
lsas_avoidance #show
## # A tibble: 26 × 28
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 14 26 1 6 1 1 0 0 1 0 1
## 2 7 28 2 4 1 0 1 2 3 2 3
## 3 15 23 1 6 1 1 1 0 1 1 0
## 4 18 25 1 7 2 1 2 3 0 2 2
## 5 25 27 2 7 0 0 1 0 0 2 0
## 6 2 32 2 9 1 0 1 1 2 0 1
## 7 8 25 2 7 1 1 0 2 1 1 1
## 8 11 26 2 6 1 1 0 0 0 0 1
## 9 102 26 1 7 0 0 0 0 0 0 0
## 10 22 29 2 8 1 2 1 1 0 2 2
## # … with 16 more rows, 17 more variables: item_8 <chr>, item_9 <chr>,
## # item_10 <chr>, item_11 <chr>, item_12 <chr>, item_13 <chr>, item_14 <chr>,
## # item_15 <chr>, item_16 <chr>, item_17 <chr>, item_18 <chr>, item_19 <chr>,
## # item_20 <chr>, item_21 <chr>, item_22 <chr>, item_23 <chr>, item_24 <chr>,
## # and abbreviated variable names ¹Subject_Number, ²EducationLevel
#is.na(lsas_avoidance) #check for na values
A brief check to the new dataset
lsas_avoidance
## # A tibble: 26 × 28
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 14 26 1 6 1 1 0 0 1 0 1
## 2 7 28 2 4 1 0 1 2 3 2 3
## 3 15 23 1 6 1 1 1 0 1 1 0
## 4 18 25 1 7 2 1 2 3 0 2 2
## 5 25 27 2 7 0 0 1 0 0 2 0
## 6 2 32 2 9 1 0 1 1 2 0 1
## 7 8 25 2 7 1 1 0 2 1 1 1
## 8 11 26 2 6 1 1 0 0 0 0 1
## 9 102 26 1 7 0 0 0 0 0 0 0
## 10 22 29 2 8 1 2 1 1 0 2 2
## # … with 16 more rows, 17 more variables: item_8 <chr>, item_9 <chr>,
## # item_10 <chr>, item_11 <chr>, item_12 <chr>, item_13 <chr>, item_14 <chr>,
## # item_15 <chr>, item_16 <chr>, item_17 <chr>, item_18 <chr>, item_19 <chr>,
## # item_20 <chr>, item_21 <chr>, item_22 <chr>, item_23 <chr>, item_24 <chr>,
## # and abbreviated variable names ¹Subject_Number, ²EducationLevel
Before doing the scoring, we convert rating scores into numeric (now they are in character format)
lsas_avoidance <-
lsas_avoidance %>%
dplyr::mutate_at(vars(item_1:item_24), as.numeric)
We calculate the sum of the scores each participant reported in the questionnaire
sum_avoidance <-
lsas_avoidance %>%
dplyr::select(item_1:item_24)
lsas_avoidance$sum_avoidance <- rowSums(sum_avoidance, na.rm=TRUE)
lsas_avoidance
## # A tibble: 26 × 29
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 14 26 1 6 1 1 0 0 1 0 1
## 2 7 28 2 4 1 0 1 2 3 2 3
## 3 15 23 1 6 1 1 1 0 1 1 0
## 4 18 25 1 7 2 1 2 3 0 2 2
## 5 25 27 2 7 0 0 1 0 0 2 0
## 6 2 32 2 9 1 0 1 1 2 0 1
## 7 8 25 2 7 1 1 0 2 1 1 1
## 8 11 26 2 6 1 1 0 0 0 0 1
## 9 102 26 1 7 0 0 0 0 0 0 0
## 10 22 29 2 8 1 2 1 1 0 2 2
## # … with 16 more rows, 18 more variables: item_8 <dbl>, item_9 <dbl>,
## # item_10 <dbl>, item_11 <dbl>, item_12 <dbl>, item_13 <dbl>, item_14 <dbl>,
## # item_15 <dbl>, item_16 <dbl>, item_17 <dbl>, item_18 <dbl>, item_19 <dbl>,
## # item_20 <dbl>, item_21 <dbl>, item_22 <dbl>, item_23 <dbl>, item_24 <dbl>,
## # sum_avoidance <dbl>, and abbreviated variable names ¹Subject_Number,
## # ²EducationLevel
lsas_avoidance <-
lsas_avoidance %>%
dplyr::mutate(scale = "lsas_avoidance", .after = "EducationLevel") #create a new column for scale
##merging lsas
sum_avoidance <-
lsas_avoidance %>%
dplyr::select(Subject_Number:EducationLevel, sum_avoidance) #select columns of interest
sum_fear <-
lsas_fear %>%
dplyr::select(Subject_Number:EducationLevel, sum_fear) #select columns of interest
lsas <- full_join(sum_avoidance, sum_fear) #we merge the two datasets
## Joining, by = c("Subject_Number", "Age", "Gender", "EducationLevel")
We now calculate the sum of the scores each participant reported for both fear and avoidance
sum <-
lsas %>%
dplyr::select(sum_fear, sum_avoidance)
lsas$sum <- rowSums(sum, na.rm=TRUE)
lsas
## # A tibble: 26 × 7
## Subject_Number Age Gender EducationLevel sum_avoidance sum_fear sum
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 14 26 1 6 14 15 29
## 2 7 28 2 4 40 41 81
## 3 15 23 1 6 15 31 46
## 4 18 25 1 7 38 29 67
## 5 25 27 2 7 9 16 25
## 6 2 32 2 9 22 28 50
## 7 8 25 2 7 23 26 49
## 8 11 26 2 6 15 22 37
## 9 102 26 1 7 5 12 17
## 10 22 29 2 8 28 23 51
## # … with 16 more rows
We finally export the dataset as an excel file
# save path
savepath <- "/Users/Giovy/Downloads/Progetti Attivi/Joint_PPS/Pt2/Respondent/lsas_scoring.xlsx"
# save to excel
write_xlsx(lsas, savepath, col_names = TRUE)
##scoring criteria the score is obtained by sum scores in fear and avoidance
score between 0-29 no social anxiety score between 30-49 Mild social anxiety score between 50-64 Moderate social anxiety score between 65-79 Marked social anxiety score between 80-94 Severe social anxiety score ≥ 95 Very severe social anxiety (e.g., Hollander, Bakalar, & Bakalar, 2005).
The total sample is composed by 26 participants
lsas %>% filter( between(sum, 0, 29) )%>%
count() #count n of participants with score between 0 and 29
## # A tibble: 1 × 1
## n
## <int>
## 1 9
There are 9 people without social anxiety
lsas %>% filter( between(sum, 30, 49) )%>%
count() #count n of participants with score between 30 and 49
## # A tibble: 1 × 1
## n
## <int>
## 1 8
There are 8 people with mild social anxiety
lsas %>% filter( between(sum, 50, 64) )%>%
count() #count n of participants with score between 50 and 64
## # A tibble: 1 × 1
## n
## <int>
## 1 4
There are 4 people with a moderate social anxiety
lsas %>% filter( between(sum, 65, 79) )%>%
count() #count n of participants with score between 65 and 79
## # A tibble: 1 × 1
## n
## <int>
## 1 3
There are 3 people with a marked social anxiety
lsas %>% filter( between(sum, 80, 94) )%>%
count() #count n of participants with score between 80 and 94
## # A tibble: 1 × 1
## n
## <int>
## 1 2
There are 2 people with a severe social anxiety
lsas %>% dplyr::filter(sum >= 95) %>%
count() #count n of participants with score >=95
## # A tibble: 1 × 1
## n
## <int>
## 1 0
There are 0 people with a very severe social anxiety
#TRIM The Transgression-Related Interpersonal Motivations Inventory is a self-report questionnaire requiring to indicate current thoughts and feelings about a person who hurt you. It contains 18 items, scored on a 5-point Likert-type (1 to 5 = Strongly Disagree, Disagree, Neutral, Agree, Strongly Agree), indicating Avoidance, Benevolence and Revenge Motivations.
We start by loading the dataset containing ratings of our sample in the questionnaire
#import file
trim_q <- read_excel("Surveys_JPPS2.xlsx", 6) #import file
trim_q <- trim_q[-1,] #remove first line
trim_q #show
## # A tibble: 26 × 22
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 14 26 1 6 1 2 5 1 4 5 1
## 2 7 28 2 4 1 2 4 1 2 5 3
## 3 15 23 1 6 3 5 5 3 2 2 4
## 4 18 25 1 7 1 2 4 1 1 3 3
## 5 25 27 2 7 1 3 1 1 5 1 5
## 6 2 32 2 9 1 5 3 1 5 1 5
## 7 8 25 2 7 1 1 4 1 1 4 3
## 8 11 26 2 6 1 3 4 1 3 1 4
## 9 102 26 1 7 1 4 2 3 1 2 4
## 10 22 29 2 8 2 3 4 1 4 5 4
## # … with 16 more rows, 11 more variables: item_8 <chr>, item_9 <chr>,
## # item_10 <chr>, item_11 <chr>, item_12 <chr>, item_13 <chr>, item_14 <chr>,
## # item_15 <chr>, item_16 <chr>, item_17 <chr>, item_18 <chr>, and abbreviated
## # variable names ¹Subject_Number, ²EducationLevel
#is.na(trim_q) #check for na values
A brief check to the new dataset
trim_q
## # A tibble: 26 × 22
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 14 26 1 6 1 2 5 1 4 5 1
## 2 7 28 2 4 1 2 4 1 2 5 3
## 3 15 23 1 6 3 5 5 3 2 2 4
## 4 18 25 1 7 1 2 4 1 1 3 3
## 5 25 27 2 7 1 3 1 1 5 1 5
## 6 2 32 2 9 1 5 3 1 5 1 5
## 7 8 25 2 7 1 1 4 1 1 4 3
## 8 11 26 2 6 1 3 4 1 3 1 4
## 9 102 26 1 7 1 4 2 3 1 2 4
## 10 22 29 2 8 2 3 4 1 4 5 4
## # … with 16 more rows, 11 more variables: item_8 <chr>, item_9 <chr>,
## # item_10 <chr>, item_11 <chr>, item_12 <chr>, item_13 <chr>, item_14 <chr>,
## # item_15 <chr>, item_16 <chr>, item_17 <chr>, item_18 <chr>, and abbreviated
## # variable names ¹Subject_Number, ²EducationLevel
Before doing the scoring, we convert rating scores into numeric (now they are in character format)
trim_q <-
trim_q %>%
dplyr::mutate_at(vars(item_1:item_18), as.numeric)
We calculate the sum of the scores each participant reported in the questionnaire for Avoidance Motivations: items 2, 5, 7, 10, 11, 15, and 18
trim_avoidance <-
trim_q %>%
dplyr::select(item_2, item_5, item_7, item_10, item_11, item_15, item_18)
trim_q$trim_avoidance <- rowSums(trim_avoidance, na.rm=TRUE)
trim_q
## # A tibble: 26 × 23
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 14 26 1 6 1 2 5 1 4 5 1
## 2 7 28 2 4 1 2 4 1 2 5 3
## 3 15 23 1 6 3 5 5 3 2 2 4
## 4 18 25 1 7 1 2 4 1 1 3 3
## 5 25 27 2 7 1 3 1 1 5 1 5
## 6 2 32 2 9 1 5 3 1 5 1 5
## 7 8 25 2 7 1 1 4 1 1 4 3
## 8 11 26 2 6 1 3 4 1 3 1 4
## 9 102 26 1 7 1 4 2 3 1 2 4
## 10 22 29 2 8 2 3 4 1 4 5 4
## # … with 16 more rows, 12 more variables: item_8 <dbl>, item_9 <dbl>,
## # item_10 <dbl>, item_11 <dbl>, item_12 <dbl>, item_13 <dbl>, item_14 <dbl>,
## # item_15 <dbl>, item_16 <dbl>, item_17 <dbl>, item_18 <dbl>,
## # trim_avoidance <dbl>, and abbreviated variable names ¹Subject_Number,
## # ²EducationLevel
We calculate the sum of the scores each participant reported in the questionnaire for Revenge Motivations: items 1, 4, 9, 13, and 17
trim_revenge <-
trim_q %>%
dplyr::select(item_1, item_4, item_9, item_13, item_17)
trim_q$trim_revenge <- rowSums(trim_revenge, na.rm=TRUE)
trim_q
## # A tibble: 26 × 24
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 14 26 1 6 1 2 5 1 4 5 1
## 2 7 28 2 4 1 2 4 1 2 5 3
## 3 15 23 1 6 3 5 5 3 2 2 4
## 4 18 25 1 7 1 2 4 1 1 3 3
## 5 25 27 2 7 1 3 1 1 5 1 5
## 6 2 32 2 9 1 5 3 1 5 1 5
## 7 8 25 2 7 1 1 4 1 1 4 3
## 8 11 26 2 6 1 3 4 1 3 1 4
## 9 102 26 1 7 1 4 2 3 1 2 4
## 10 22 29 2 8 2 3 4 1 4 5 4
## # … with 16 more rows, 13 more variables: item_8 <dbl>, item_9 <dbl>,
## # item_10 <dbl>, item_11 <dbl>, item_12 <dbl>, item_13 <dbl>, item_14 <dbl>,
## # item_15 <dbl>, item_16 <dbl>, item_17 <dbl>, item_18 <dbl>,
## # trim_avoidance <dbl>, trim_revenge <dbl>, and abbreviated variable names
## # ¹Subject_Number, ²EducationLevel
We calculate the sum of the scores each participant reported in the questionnaire for Benevolence Motivations: items 3, 6, 8, 12, 14, and 16
trim_benevolence <-
trim_q %>%
dplyr::select(item_3, item_6, item_8, item_12, item_14, item_16)
trim_q$trim_benevolence <- rowSums(trim_benevolence, na.rm=TRUE)
trim_q
## # A tibble: 26 × 25
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 14 26 1 6 1 2 5 1 4 5 1
## 2 7 28 2 4 1 2 4 1 2 5 3
## 3 15 23 1 6 3 5 5 3 2 2 4
## 4 18 25 1 7 1 2 4 1 1 3 3
## 5 25 27 2 7 1 3 1 1 5 1 5
## 6 2 32 2 9 1 5 3 1 5 1 5
## 7 8 25 2 7 1 1 4 1 1 4 3
## 8 11 26 2 6 1 3 4 1 3 1 4
## 9 102 26 1 7 1 4 2 3 1 2 4
## 10 22 29 2 8 2 3 4 1 4 5 4
## # … with 16 more rows, 14 more variables: item_8 <dbl>, item_9 <dbl>,
## # item_10 <dbl>, item_11 <dbl>, item_12 <dbl>, item_13 <dbl>, item_14 <dbl>,
## # item_15 <dbl>, item_16 <dbl>, item_17 <dbl>, item_18 <dbl>,
## # trim_avoidance <dbl>, trim_revenge <dbl>, trim_benevolence <dbl>, and
## # abbreviated variable names ¹Subject_Number, ²EducationLevel
##scoring criteria the score is obtained by sum scores for each motivations, but revenge ad avoidance are reversed. The result is a scoring of Forgiveness.
Therefore, we recode values of all Avoidance Motivations: items 2, 5, 7, 10, 11, 15, and 18 (from 5 to 1)
trim_q <-
trim_q %>%
dplyr::mutate(item_2= case_when(item_2 == "5" ~ "1",
item_2 == "4" ~ "2",
item_2 == "3" ~ "3",
item_2 == "2" ~ "4",
item_2 == "1" ~ "5"
)) #recode value
trim_q <-
trim_q %>%
dplyr::mutate(item_5= case_when(item_5 == "5" ~ "1",
item_5 == "4" ~ "2",
item_5 == "3" ~ "3",
item_5 == "2" ~ "4",
item_5 == "1" ~ "5"
)) #recode value
trim_q <-
trim_q %>%
dplyr::mutate(item_7= case_when(item_7 == "5" ~ "1",
item_7 == "4" ~ "2",
item_7 == "3" ~ "3",
item_7 == "2" ~ "4",
item_7 == "1" ~ "5"
)) #recode value
trim_q <-
trim_q %>%
dplyr::mutate(item_10= case_when(item_10 == "5" ~ "1",
item_10 == "4" ~ "2",
item_10 == "3" ~ "3",
item_10 == "2" ~ "4",
item_10 == "1" ~ "5"
)) #recode value
trim_q <-
trim_q %>%
dplyr::mutate(item_11= case_when(item_11 == "5" ~ "1",
item_11 == "4" ~ "2",
item_11 == "3" ~ "3",
item_11 == "2" ~ "4",
item_11 == "1" ~ "5"
)) #recode value
trim_q <-
trim_q %>%
dplyr::mutate(item_15= case_when(item_15 == "5" ~ "1",
item_15 == "4" ~ "2",
item_15 == "3" ~ "3",
item_15 == "2" ~ "4",
item_15 == "1" ~ "5"
)) #recode value
trim_q <-
trim_q %>%
dplyr::mutate(item_18= case_when(item_18 == "5" ~ "1",
item_18 == "4" ~ "2",
item_18 == "3" ~ "3",
item_18 == "2" ~ "4",
item_18 == "1" ~ "5"
)) #recode value
Then, we recode values of all Revenge Motivations: items 1, 4, 9, 13, and 17 (from 5 to 1) Then, we recode values of all the remaining items, because Likert scale we used was not corrected (the original one ranges from 0 to 3, not from 1 to 4)
trim_q <-
trim_q %>%
dplyr::mutate(item_1= case_when(item_1 == "5" ~ "1",
item_1 == "4" ~ "2",
item_1 == "3" ~ "3",
item_1 == "2" ~ "4",
item_1 == "1" ~ "5"
)) #recode value
trim_q <-
trim_q %>%
dplyr::mutate(item_4= case_when(item_4 == "5" ~ "1",
item_4 == "4" ~ "2",
item_4 == "3" ~ "3",
item_4 == "2" ~ "4",
item_4 == "1" ~ "5"
)) #recode value
trim_q <-
trim_q %>%
dplyr::mutate(item_9= case_when(item_9 == "5" ~ "1",
item_9 == "4" ~ "2",
item_9 == "3" ~ "3",
item_9 == "2" ~ "4",
item_9 == "1" ~ "5"
)) #recode value
trim_q <-
trim_q %>%
dplyr::mutate(item_13= case_when(item_13 == "5" ~ "1",
item_13 == "4" ~ "2",
item_13 == "3" ~ "3",
item_13 == "2" ~ "4",
item_13 == "1" ~ "5"
)) #recode value
trim_q <-
trim_q %>%
dplyr::mutate(item_17= case_when(item_17 == "5" ~ "5",
item_17 == "4" ~ "4",
item_17 == "3" ~ "3",
item_17 == "2" ~ "2",
item_17 == "1" ~ "1"
)) #recode value
Before doing the scoring, we convert rating scores into numeric (now they are in character format)
trim_q <-
trim_q %>%
dplyr::mutate_at(vars(item_1:item_18), as.numeric)
We calculate the sum of the scores for all the item to obtain Forgiveness score
trim_forgiveness <-
trim_q %>%
dplyr::select(item_1:item_18)
trim_q$trim_forgiveness <- rowSums(trim_forgiveness, na.rm=TRUE)
trim_q
## # A tibble: 26 × 26
## Subje…¹ Age Gender Educa…² item_1 item_2 item_3 item_4 item_5 item_6 item_7
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 14 26 1 6 5 4 5 5 2 5 5
## 2 7 28 2 4 5 4 4 5 4 5 3
## 3 15 23 1 6 3 1 5 3 4 2 2
## 4 18 25 1 7 5 4 4 5 5 3 3
## 5 25 27 2 7 5 3 1 5 1 1 1
## 6 2 32 2 9 5 1 3 5 1 1 1
## 7 8 25 2 7 5 5 4 5 5 4 3
## 8 11 26 2 6 5 3 4 5 3 1 2
## 9 102 26 1 7 5 2 2 3 5 2 2
## 10 22 29 2 8 4 3 4 5 2 5 2
## # … with 16 more rows, 15 more variables: item_8 <dbl>, item_9 <dbl>,
## # item_10 <dbl>, item_11 <dbl>, item_12 <dbl>, item_13 <dbl>, item_14 <dbl>,
## # item_15 <dbl>, item_16 <dbl>, item_17 <dbl>, item_18 <dbl>,
## # trim_avoidance <dbl>, trim_revenge <dbl>, trim_benevolence <dbl>,
## # trim_forgiveness <dbl>, and abbreviated variable names ¹Subject_Number,
## # ²EducationLevel
We finally export the dataset as an excel file
# save path
savepath <- "/Users/Giovy/Downloads/Progetti Attivi/Joint_PPS/Pt2/Respondent/trim_scoring.xlsx"
# save to excel
write_xlsx(trim_q, savepath, col_names = TRUE)