# if you haven't run this code before, you'll need to download the below packages first
# instructions on how to do this are included in the video
# but as a reminder, you use the packages tab to the right
library(psych) # for the describe() command
library(expss) # for the cross_cases() command
## Loading required package: maditr
##
## To get total summary skip 'by' argument: take_all(mtcars, mean)
##
## Attaching package: 'maditr'
## The following object is masked from 'package:base':
##
## sort_by
#import lab data
#import HW mydata.csv
d3 <- read.csv(file="Data/mydata.csv", header = T)
table(d3$gender)
##
## f m nb
## 1546 527 31
table(d3$age)
##
## 1 between 18 and 25 2 between 26 and 35 3 between 36 and 45 4 over 45
## 1937 113 37 17
hist(d3$moa_independence)
hist(d3$swb)
hist(d3$belong)
hist(d3$socmeduse)
I analyzed the skew and kurtosis of the continuous variables and all were within the accepted range (-2/+2).
describe(d3)
## vars n mean sd median trimmed mad min max range skew
## gender* 1 2104 1.28 0.48 1.00 1.21 0.00 1.0 3 2.0 1.37
## age* 2 2104 1.11 0.43 1.00 1.00 0.00 1.0 4 3.0 4.42
## moa_independence 3 2104 3.54 0.47 3.67 3.61 0.49 1.0 4 3.0 -1.49
## swb 4 2104 4.43 1.33 4.50 4.49 1.48 1.0 7 6.0 -0.36
## belong 5 2104 3.21 0.61 3.20 3.23 0.59 1.3 5 3.7 -0.27
## socmeduse 6 2104 34.24 8.63 35.00 34.51 7.41 11.0 55 44.0 -0.30
## kurtosis se
## gender* 0.76 0.01
## age* 21.13 0.01
## moa_independence 2.77 0.01
## swb -0.49 0.03
## belong -0.12 0.01
## socmeduse 0.18 0.19
cross_cases(d3, gender, age)
|  age | ||||
|---|---|---|---|---|
| Â 1 between 18 and 25Â | Â 2 between 26 and 35Â | Â 3 between 36 and 45Â | Â 4 over 45Â | |
|  gender | ||||
|    f | 1439 | 68 | 27 | 12 |
|    m | 468 | 45 | 9 | 5 |
|    nb | 30 | 1 | ||
|    #Total cases | 1937 | 113 | 37 | 17 |
plot(d3$moa_independence, d3$swb,
main="Scatterplot of moa_independence and swb",
xlab = "moa_independence",
ylab = "swb")
plot(d3$belong, d3$socmeduse,
main="Scatterplot of belong and socmeduse",
xlab = "belong",
ylab = "socmeduse")
boxplot(data=d3, moa_independence~age,
main="Boxplot of age and moa_independence",
xlab = "age",
ylab = "moa_independence")
boxplot(data=d3, belong~gender,
main="Boxplot of gender and belong",
xlab = "gender",
ylab = "belong")