#library(tidyverse)
library(dplyr)
library(purrr)
dataset=read.csv('psichiR_Apr2024.csv')
#skim=skimr::skim(dataset)
sum(is.na(dataset))
## [1] 21742
sum(is.null(dataset))
## [1] 0
o Create by COShindivid (Horizontal Individualism) doing COS1 + COS5 + COS9 + COS13
o Create disengaged (FACEdisen) by FACES3 + FACES9 + FACES15 + FACES21 + FACES27 + FACES33 + FACES39
o Create enmeshed (FACEenmesh) by FACES4 + FACES10 + FACES16 + FACES22 + FACES28 + FACES34 + FACES40
o Create Rigid (FACErigid) by FACES5 + FACES11 + FACES17 + FACES23 + FACES29 + FACES35 + FACES41
o Create Chaotic (FACEchaotic) by FACES6 + FACES12 + FACES18 + FACES24 + FACES30 + FACES36 + FACES42
o Create Communication (FACEcomm) by FACES43 + FACES44 + FACES45 + FACES46 + FACES47 + FACES48 + FACES49 + FACES50 + FACES51 + FACES52
o Create Satisfaction (FACEsatis) by FACES53 + FACES54 + FACES55 + FACES56 + FACES57 + FACES58 + FACES59 + FACES60 + FACES61 + FACES62
dataset1=dataset %>%
mutate(COShindivid=COS1 + COS5 + COS9 + COS13,
FACEdisen= FACES3 + FACES9 + FACES15 + FACES21 + FACES27 + FACES33 + FACES39,
FACEenmesh= FACES4 + FACES10 + FACES16 + FACES22 + FACES28 + FACES34 + FACES40,
FACErigid= FACES5 + FACES11 + FACES17 + FACES23 + FACES29 + FACES35 + FACES41,
FACEchaotic= FACES6 + FACES12 + FACES18 + FACES24 + FACES30 + FACES36 + FACES42,
FACEcomm= FACES43 + FACES44 + FACES45 + FACES46 + FACES47 + FACES48 + FACES49 + FACES50 + FACES51 + FACES52,
FACEsatis= FACES53 + FACES54 + FACES55 + FACES56 + FACES57 + FACES58 + FACES59 + FACES60 + FACES61 + FACES62) %>%
select(COS1,COShindivid,FACEdisen,FACEenmesh,FACErigid,FACEchaotic,FACEcomm,FACEsatis,everything())
library(purrr)
purr_list=data.frame(FACEenmesh=dataset1$FACEenmesh,COShindivid=dataset1$COShindivid)
desc_stat=function(x) {
list(mean=mean(x,na.rm=T),sd=sd(x,na.rm=T),
median=median(x,na.rm=T),range=range(x,na.rm=T))
}
stats=purr_list %>%
map(desc_stat) %>%
as.data.frame()
print(stats) #the mean, standard deviation, median, and range for FACEenmesh and COShindivid
## FACEenmesh.mean FACEenmesh.sd FACEenmesh.median FACEenmesh.range
## 1 15.22561 4.867272 14 7
## 2 15.22561 4.867272 14 35
## COShindivid.mean COShindivid.sd COShindivid.median COShindivid.range
## 1 27.21285 5.336077 28 9
## 2 27.21285 5.336077 28 36
summary(dataset1$FACEsatis)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 10.00 30.00 38.00 36.83 42.00 50.00 21
FACE=na.omit(dataset1$FACEsatis) %>%
data.frame() %>%
rename(face=1)
summary(FACE)
## face
## Min. :10.00
## 1st Qu.:30.00
## Median :38.00
## Mean :36.83
## 3rd Qu.:42.00
## Max. :50.00
boxplot(FACE$face,main='Party Crashers or Trendsetters? A Tale of Two Data Points',xlab='FACEsatis',ylab='Count',lwd=1.5,boxfill='darkgreen',pch=1.5,outcol='red')
#library(ggplot2)
dataset1 %>%
ggplot(aes(y=FACEsatis))+
theme_bw()+
geom_boxplot(fill='darkgreen',outlier.color = 'red',lwd=1.5,outlier.size = 2)+
labs(title = 'Party Crashers or Trendsetters? A Tale of Two Data Points',x='FACEsatis',y='Count')+
theme(plot.title = element_text(hjust = .5))
summary(dataset1$COShindivid)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 9.00 23.00 28.00 27.21 31.00 36.00 11
COSH=na.omit(dataset1$COShindivid) %>%
data.frame()
summary(COSH)
## .
## Min. : 9.00
## 1st Qu.:23.00
## Median :28.00
## Mean :27.21
## 3rd Qu.:31.00
## Max. :36.00
hist(COSH$.,freq=F,main = 'Long Tail, Big Dreams: A Look at Our Left-Skewed Distribution',ylab = 'Density',xlab='COShindivid',col='darkgreen')
lines(density(COSH$.),lwd=2,col='red')
shapiro.test(COSH$.) #No, COShindivid violates normality
##
## Shapiro-Wilk normality test
##
## data: COSH$.
## W = 0.97248, p-value = 0.00000004639
#library(ggplot)
dataset1 %>%
ggplot(aes(x=COShindivid))+
theme_bw()+
geom_histogram(aes(y=..density..),col='black',fill='darkgreen',show.legend = F,bins=15)+
geom_density(col='red',lwd=2)+
labs(title = 'Long Tail, Big Dreams: A Look at Our Left-Skewed Distribution')+
theme(plot.title = element_text(hjust = .5))
cor_data=dataset1[,c(2:8)]
cor_matrix=cor_data %>%
na.omit() %>%
cor() %>%
round(digits = 2) %>%
as.data.frame()
print(cor_matrix)
## COShindivid FACEdisen FACEenmesh FACErigid FACEchaotic FACEcomm
## COShindivid 1.00 0.10 -0.05 0.01 -0.02 -0.01
## FACEdisen 0.10 1.00 0.54 0.06 0.71 -0.47
## FACEenmesh -0.05 0.54 1.00 0.31 0.55 -0.18
## FACErigid 0.01 0.06 0.31 1.00 -0.03 0.23
## FACEchaotic -0.02 0.71 0.55 -0.03 1.00 -0.44
## FACEcomm -0.01 -0.47 -0.18 0.23 -0.44 1.00
## FACEsatis 0.06 -0.44 -0.13 0.18 -0.41 0.78
## FACEsatis
## COShindivid 0.06
## FACEdisen -0.44
## FACEenmesh -0.13
## FACErigid 0.18
## FACEchaotic -0.41
## FACEcomm 0.78
## FACEsatis 1.00
use_color=colorRampPalette(c('lightblue','darkblue'))
cor_matrix %>%
as.matrix() %>%
heatmap(margins = c(10,5),col=use_color(100),main = 'A Heatmap Exposé on Satisfaction and Communication')
sessionInfo()
## R version 4.3.2 (2023-10-31 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19045)
##
## Matrix products: default
##
##
## locale:
## [1] LC_COLLATE=English_United States.utf8
## [2] LC_CTYPE=English_United States.utf8
## [3] LC_MONETARY=English_United States.utf8
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.utf8
##
## time zone: America/New_York
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] purrr_1.0.2 dplyr_1.1.4 conflicted_1.2.0 lubridate_1.9.3
## [5] janitor_2.2.0 ggplot2_3.5.0
##
## loaded via a namespace (and not attached):
## [1] jsonlite_1.8.7 gtable_0.3.4 highr_0.10 compiler_4.3.2
## [5] tidyselect_1.2.0 stringr_1.5.0 snakecase_0.11.1 jquerylib_0.1.4
## [9] scales_1.3.0 yaml_2.3.7 fastmap_1.1.1 R6_2.5.1
## [13] labeling_0.4.3 generics_0.1.3 knitr_1.45 tibble_3.2.1
## [17] munsell_0.5.0 bslib_0.5.1 pillar_1.9.0 rlang_1.1.1
## [21] utf8_1.2.3 cachem_1.0.8 stringi_1.7.12 xfun_0.40
## [25] sass_0.4.7 timechange_0.2.0 memoise_2.0.1 cli_3.6.1
## [29] withr_2.5.1 magrittr_2.0.3 digest_0.6.33 grid_4.3.2
## [33] rstudioapi_0.15.0 lifecycle_1.0.3 vctrs_0.6.5 evaluate_0.22
## [37] glue_1.6.2 farver_2.1.1 fansi_1.0.4 colorspace_2.1-0
## [41] rmarkdown_2.25 tools_4.3.2 pkgconfig_2.0.3 htmltools_0.5.6.1