##read in data

#load package
#install.packages("tinytex")
library(psych)
library(knitr)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.6     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.4     ✓ stringr 1.4.0
## ✓ readr   2.0.2     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x ggplot2::%+%()   masks psych::%+%()
## x ggplot2::alpha() masks psych::alpha()
## x dplyr::filter()  masks stats::filter()
## x dplyr::lag()     masks stats::lag()
library(tinytex)
LTCC <- read.csv("LTCCdata.csv")

#Create ShoCCS composites

#composite for cr short
LTCC$c_ref_S <- with(data = LTCC, (cr_3.t1 + cr_6.t1 + cr_7.t1 + cr_8.t1) / 4)

#composite for cm short
LTCC$c_mot_S <- with(data = LTCC, (cm_2.t1 + cm_5.t1 + cm_7.t1 + cm_8.t1) / 4)

#composite for ca short
LTCC$c_act_S <- with(data = LTCC, (ca_1.t1 + ca_2.t1 + ca_4.t1 + ca_5.t1 + ca_9.t1) / 5)

#Examine the gender breakdown of the sample by YO or YLC

table(LTCC$gender.t1, LTCC$DSET) %>% kable()
0 1
0 102 173
1 61 79
2 2 6
4 2 7
# 0 = girl; 1 = boy; 2 = I want to describe; 4 = I don't want to answer

#For DSET: 0 = YLC and 1 = YO

#Examine the racial breakdown of the sample by YO or YLC

table(LTCC$d_self.t1, LTCC$DSET) %>% kable()
0 1
0 30 27
1 50 52
2 46 153
3 24 17
4 18 14
# 0 = Asian/Indian; 1 = Black/African American; 2 = Latino/Hispanic; 3 = two or more races; 4 = White/caucasion

#Time in Program Descriptives by YO or YLC

table(LTCC$tip.t1, LTCC$DSET) %>% kable()
0 1
0 10 27
1 10 35
2 5 60
3 104 61
4 17 41
5 16 16
6 6 25
#"This is my first day." = 0; "A few days" = 1; "A few weeks" = 2; "A few months" = 3; "1 year" = 4;
#"2 years" = 5; "More than 2 years" = 6

describeBy(LTCC$tip.t1, LTCC$DSET, mat = TRUE) %>% kable()
item group1 vars n mean sd median trimmed mad min max range skew kurtosis se
X11 1 0 1 168 3.071429 1.269501 3 3.117647 0.0000 0 6 6 -0.3076158 1.0241500 0.0979442
X12 2 1 1 265 2.762264 1.694490 3 2.708920 1.4826 0 6 6 0.2475617 -0.6314806 0.1040917

#Descriptives for critical reflection by YO or YLC

describeBy(LTCC$c_ref_S, LTCC$DSET, mat = TRUE) %>% kable()
item group1 vars n mean sd median trimmed mad min max range skew kurtosis se
X11 1 0 1 184 4.000000 1.440296 4.250 4.114865 1.297275 1 6 5 -0.6041837 -0.5103667 0.1061801
X12 2 1 1 318 4.213837 1.548974 4.625 4.379883 1.667925 1 6 5 -0.7510792 -0.5560536 0.0868621

#Descriptives for Critical Motivation by YO or YLC

describeBy(LTCC$c_mot_S, LTCC$DSET, mat = TRUE) %>% kable()
item group1 vars n mean sd median trimmed mad min max range skew kurtosis se
X11 1 0 1 182 5.383242 0.8077025 5.75 5.525685 0.37065 1.25 6 4.75 -1.991195 5.494142 0.0598709
X12 2 1 1 321 5.288162 0.8071362 5.50 5.426070 0.74130 1.75 6 4.25 -1.426113 1.950706 0.0450499

#Descriptives for Critical Action by YO or YLC

describeBy(LTCC$c_act_S, LTCC$DSET, mat = TRUE) %>% kable()
item group1 vars n mean sd median trimmed mad min max range skew kurtosis se
X11 1 0 1 180 2.19 1.043046 1.8 2.079167 0.88956 1 5 4 0.7435757 -0.4034886 0.0777440
X12 2 1 1 320 2.39 1.193987 2.2 2.293750 1.48260 1 5 4 0.4267449 -1.0429388 0.0667459