ypt <- read.csv(file="C:/Users/YujieCui/My Documents/R/R git projects/YPT ANALYSIS PROJECT/ypt_final_master.csv", header=TRUE, sep=",", stringsAsFactors = FALSE, na.strings = "")

ypt$sex <- factor(ypt$sex,
                  levels = c(1, 2),
                  labels = c("male", "female"))

ypt$treatment <-
  factor(ypt$treatment,
         levels = c(1, 2),
         labels = c("YPT", "SOC"))
ypt$race3 <-
  factor(
    ypt$race3,
    levels = c(1, 2, 3, 4),
    labels = c("Black", "Hispanics", "White", "Other")
  )
ypt$HBP <-
  factor(
    ypt$HBP,
    levels = c(1, 2, 3),
    labels = c("Yes", "No", "Don't know (HBP)")
  )
ypt$PKD <-
  factor(
    ypt$PKD,
    levels = c(1, 2, 3),
    labels = c("Yes", "No", "Don't know (PKD)")
  )
ypt$Diabetes <-
  factor(
    ypt$Diabetes,
    levels = c(1, 2, 3),
    labels = c("Yes", "No", "Don't know (Diabetes)")
  )
ypt$dialysis <-
  factor(ypt$dialysis,
         levels = c(1, 2),
         labels = c("Yes", "No (dialysis)"))

ypt$education <-
  factor(
    ypt$education,
    levels = c(1, 2, 3, 4, 5, 6, 7, 9),
    labels = c(
      "8th grade or less",
      "Some high school",
      "High school diploma or GED",
      "Some college or vocational school",
      "College or vocational school degree",
      "Some professional or graduate school",
      "Professional or graduate degree",
      "Prefer not to answer"))

ypt$employment <-
  factor(
    ypt$employment,
    levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
    labels = c(
      "full-time",
      "part-time",
      "employment of others in household",
      "retirement savings/pension",
      "social security",
      "unemployment",
      "welfare/TANF",
      "disability due to kidney disease",
      "disability due to other causes",
      "other: student loans, homeless"
    )
  )

# import labels for process evaluation variables 

df_labels <- read.csv("I:/RESEARCH PROJECTS/RCTPROJECTS/R01 ExpertSystem/DATA COMPONENTS/CODEBOOKS/process_eval_variable_and_labels.csv",header=TRUE, sep=",", stringsAsFactors = FALSE, na.strings = "" )

Data Exploring

The dataset

This dataset has 803 obs and ~80 process evaluation retlated variables.

About 224 patients consistently answered the process evaluation questions. Below is a quick look of variables, labels, N, missingness, and ranges.

df_eval <- ypt %>% 
  select(sex, race3, treatment, cch_med:more_info2, -help_coach, -help_print, -list_question, -list_help, -contains("_most"), -contains("_least"),-report_minutes, -print_minutes, -contains("trt_opt2_b34_"))   # removed open ended questions. 

# merge with labels


df_desc <- dlookr::describe(df_eval) %>% 
  select(variable, n, missing=na, min = p00, median = p50,max = p100)              # in line renaming

df_join <- left_join(df_desc, df_labels)

df_join <- df_join %>% select(variable, label, everything()) 

datatable( data = df_join, 
           rownames = F,
                extensions = 'Buttons'
                , options = list( 
                  dom = "Blfrtip"
                  , buttons = 
                    list("copy", list(
                      extend = "collection"
                      , buttons = c("csv", "excel", "pdf")
                      , text = "Download"
                    ) ) # end of buttons customization
                   
                   # customize the length menu
                  , lengthMenu = list( c(10, 20, -1) # declare values
                                       , c(10, 20, "All") # declare titles
                  ) # end of lengthMenu customization
                  , pageLength = 10
                   
                   
                ) # end of options
               
     ) # end of datatables

Label variables

To makes stats table more readable.

Common levels shared by variables:

1, Strongly Disagree | 2, Disagree | 3, Neither Agree nor Disagree | 4, Agree | 5, Strongly Agree;

1, Not at all helpful | 2, Somewhat helpful | 3, Moderately helpful | 4, Very helpful;

1, Yes | 2, No

1, Never | 2, Sometimes | 3, Usually | 4, Always

varnames <- colnames(df_eval %>% select(cch_med:cch_ins))

  df_eval[varnames] <- lapply(df_eval[varnames], function(x) factor(x, levels = c(1,2,3,4), labels = c("Never", "Sometimes", "Usually","Always")))


evalnames <- df_eval %>% select(eval_easy:vid_over) %>% colnames()
  
  df_eval[evalnames] <- lapply(df_eval[evalnames], function(x) factor(x, levels = c(1,2,3,4,5), labels = c("Strong disagree", "Disagree", "Neither Agree nor Disagree","Agree", "Strongly agree")))

helpnames <- df_eval %>% select(contains("help_"), -help_yes_no) %>% colnames()

  df_eval[helpnames] <- lapply(df_eval[helpnames], function(x) factor(x, levels = c(1,2,3,4), labels = c("Not at all helpful", "Somewhat helpful", "Moderately helpful","Very helpful")))

df_eval$help_yes_no <- factor(df_eval$help_yes_no, levels = c(1,2), labels = c("Yes", "No"))
# treawtment options check all apply  df_eval$trt_opt2_b34 <- factor(df_eval$help_yes_no, levels = c(1,2), labels = c("Yes", "No"))

optnames <- df_eval %>% select(opt_avail2:dec_sat2, part_stdy2:more_info2) %>% colnames()

df_eval[optnames] <- lapply(df_eval[optnames], function(x) factor(x, levels = c(1,2,3,4,5), labels = c("Strong disagree", "Disagree", "Neither Agree nor Disagree","Agree", "Strongly agree")))

factnames <- df_eval %>% select(facts_dec:facts_liv) %>% colnames()

  df_eval[factnames] <- lapply(df_eval[factnames], function(x) factor(x, levels = c(1,2,3,4), labels = c("Completely disagree", "Somewhat disagree", "Somewhat agree","Completely agree")))

Table 1. Overall stats of process evaluation variables.

vars <- colnames(df_eval)

tab1 <- CreateTableOne(vars, factorVars = vars, data = df_eval) 

df_tab1 <- print(tab1,printToggle = F, showAllLevels = T) 


#write.csv(df_tab1, "Table1_Overall_Stats.csv")

table1 <- read_xlsx("table_1.xlsx")


options(knitr.kable.NA = '')  # suppress empty as NA in the table

datatable( data = table1, 
           rownames = F,
                extensions = 'Buttons'
                , options = list( 
                  dom = "Blfrtip"
                  , buttons = 
                    list("copy", list(
                      extend = "collection"
                      , buttons = c("csv", "excel", "pdf")
                      , text = "Download"
                    ) ) # end of buttons customization
                   
                   # customize the length menu
                  , lengthMenu = list( c(25, 50, -1) # declare values
                                       , c(25, 50, "All") # declare titles
                  ) # end of lengthMenu customization
                  , pageLength = 25
                   
                   
                ) # end of options
               
     ) # end of datatables

Table 2. process evaluation variables by race.

The below variables might be interesting to investigate as they showed statistical significance among race groups: cch_med, How often did the coaches use medical words you did not understand?
cch_int, How often did they show interest in your questions and concerns?
print_help, The print materials were helpful.
print_info, I can trust the information provided in the print materials.
print_race, The print materials are suitable for people of my race and ethnic background.
edu_ldkt, Increased my interest in living donor transplant.

edu_ddkt_ques, Left me with more questions than answers about getting a deceased donor transplant
vid_help, The video was helpful.
ben_mat2, I am clear about which benefits matter most to me.
adv_chc2, I have enough advice from others to make a choice.
facts_liv, I have all the facts I need to make an informed decision about whether or not pursue living donation.

vars <- colnames(df_eval)

tab1 <- CreateTableOne(vars, factorVars = vars, strata = "race3", data = df_eval) 

df_tab1 <- print(tab1,printToggle = F, showAllLevels = F) 


#write.csv(df_tab1, "Table1_Overall_Stats.csv")

options(knitr.kable.NA = '')  # suppress empty as NA in the table

datatable( data = df_tab1, 
           rownames = T,
                extensions = 'Buttons'
                , options = list( 
                  dom = "Blfrtip"
                  , buttons = 
                    list("copy", list(
                      extend = "collection"
                      , buttons = c("csv", "excel", "pdf")
                      , text = "Download"
                    ) ) # end of buttons customization
                   
                   # customize the length menu
                  , lengthMenu = list( c(25, 50, -1) # declare values
                                       , c(25, 50, "All") # declare titles
                  ) # end of lengthMenu customization
                  , pageLength = 25
                   
                   
                ) # end of options
               
     ) # end of datatables

Table 3. process evaluation variables by gender

These variables might be interesting to investigate as they showed statistical significance between gender: help_yes_no, Was there something else you did that was helpful?
risk_mat2, I am clear about which risks and side effects matter most to me.
ben_risk2, I am clear about which is more important to me (the benefits or the risks and side effects).
best_chc2, I am clear about the best choice for me.
sure_chc2, I feel sure about what to choose.
dec_sat2, I am satisfied with my decision.

vars <- colnames(df_eval)

tab1 <- CreateTableOne(vars, factorVars = vars, strata = "sex", data = df_eval) 

df_tab1 <- print(tab1,printToggle = F, showAllLevels = F) 


#write.csv(df_tab1, "Table1_Overall_Stats.csv")

options(knitr.kable.NA = '')  # suppress empty as NA in the table

datatable( data = df_tab1, 
           rownames = T,
                extensions = 'Buttons'
                , options = list( 
                  dom = "Blfrtip"
                  , buttons = 
                    list("copy", list(
                      extend = "collection"
                      , buttons = c("csv", "excel", "pdf")
                      , text = "Download"
                    ) ) # end of buttons customization
                   
                   # customize the length menu
                  , lengthMenu = list( c(25, 50, -1) # declare values
                                       , c(25, 50, "All") # declare titles
                  ) # end of lengthMenu customization
                  , pageLength = 25
                   
                   
                ) # end of options
               
     ) # end of datatables