################################################################################################################## #update path! setwd("C:/....") library(foreign) dat = as.data.frame(read.spss("EMAAge_HRQOL_peerj.sav", use.value.labels=T)) # dat0 = subset(dat, select = c(dropout, study_center, Sex, Age, CASMIN, migration, livingsituation, Personshousehold, proxy, Pre_fracture_dependency, Fracture_type, Charlson_commorbity_index, polypharmacy, Social_support, subjective_need, Surgery, ICU_episode, Referral_to_rehabilitation_facility, Malnutrition, PHQ_4, OHS, EQ5Dindex_diff, vas_diff, EQ5Dindex, EQ5Dindex_FU, vas_retro_bl, vas_today_a, Died)) ##################################################################################################### table(dat0$study_center) dat0$study_center <- relevel(dat0$study_center, ref = "University hospital") table(dat0$Sex) dat0$Sex <- relevel(dat0$Sex, ref = "female") table(dat0$Age) table(dat0$CASMIN) table(dat0$migration) table(dat0$livingsituation) #### table(dat0$Personshousehold) levels(dat0$Personshousehold)[levels(dat0$Personshousehold)=="I don't know"] <- NA levels(dat0$Personshousehold) <- c("Own home alone", "Own home with others", "Other") dat0$Personshousehold[dat0$livingsituation=="Facility/other"] <- "Other" dat0$Personshousehold <- relevel(dat0$Personshousehold, ref = "Own home with others") table(dat0$proxy) table(dat0$Pre_fracture_dependency) #### table(dat0$Fracture_type) levels(dat0$Fracture_type)[levels(dat0$Fracture_type)=="Pertrochanteric fracture" | levels(dat0$Fracture_type)=="Subtrochanteric fracture"] <- "Per- or Subtrochanteric fracture" #### Exclusion of fracture type "Periprosthetic fracture", because only 5 times dat0 <- dat0[!(dat0$Fracture_type=="Periprosthetic fracture"),] levels(dat0$Fracture_type)[levels(dat0$Fracture_type)=="Periprosthetic fracture"] <- NA table(dat0$Charlson_commorbity_index) dat0$Charlson_commorbity_index_cat <- dat0$Charlson_commorbity_index dat0$Charlson_commorbity_index_cat[dat0$Charlson_commorbity_index_cat>2] <- "3+" dat0$Charlson_commorbity_index_cat <- as.factor(dat0$Charlson_commorbity_index_cat) levels(dat0$Charlson_commorbity_index_cat) <- c("0","1", "2", "3+") table(dat0$Charlson_commorbity_index_cat) table(dat0$polypharmacy) table(dat0$Social_support) levels(dat0$Social_support)[levels(dat0$Social_support)=="I don't know / n.a."] <- NA levels(dat0$Social_support)[levels(dat0$Social_support)=="None" | levels(dat0$Social_support)=="1 or 2 people"] <- "0 - 2 people" table(dat0$subjective_need) table(dat0$Surgery) #### Exclusion of patients without OP dat0 <- dat0[!(dat0$Surgery=="No surgery"),] levels(dat0$Surgery)[levels(dat0$Surgery)=="No surgery"] <- NA dat0$Surgery <- relevel(dat0$Surgery, ref="Internal Fixation") table(dat0$ICU_episode) levels(dat0$ICU_episode)[levels(dat0$ICU_episode)=="n.a."] <- NA dat0$ICU_episode <- relevel(dat0$ICU_episode, ref = "no") table(dat0$Referral_to_rehabilitation_facility) dat0$Referral_to_rehabilitation_facility <- relevel(dat0$Referral_to_rehabilitation_facility, ref = "yes") table(dat0$Malnutrition) table(dat0$PHQ_4) dat0$PHQ_4_cat[dat0$PHQ_4>5] <- ">=6" dat0$PHQ_4_cat[dat0$PHQ_4<6] <- "<6" dat0$PHQ_4_cat <- as.factor(dat0$PHQ_4_cat) table(dat0$PHQ_4_cat) table(dat0$OHS) #####-------------- Exclusion of patients that died -----------------##### table(dat0$Died) dat0 <- dat0[dat0$Died=="no",] #### dependent variables table(dat0$EQ5Dindex_diff) table(dat0$vas_diff) table(dat0$EQ5Dindex) dat0$EQ5Dindex[dat0$EQ5Dindex==9] <- NA table(dat0$EQ5Dindex_FU) dat0$EQ5Dindex_FU[dat0$EQ5Dindex_FU==9] <- NA table(dat0$vas_retro_bl) table(dat0$vas_today_a) head(dat0) summary(dat0) ## delete variable "Died", dataset is reduced to living patients dat1 = subset(dat0, select = c(study_center, Sex, Age, CASMIN, migration, Personshousehold, proxy, Pre_fracture_dependency, Fracture_type, Charlson_commorbity_index_cat, polypharmacy, Social_support, subjective_need, Surgery, ICU_episode, Referral_to_rehabilitation_facility, Malnutrition, PHQ_4_cat, OHS, EQ5Dindex_diff, vas_diff, EQ5Dindex, EQ5Dindex_FU, vas_retro_bl, vas_today_a)) ###################################################################################################################### ############################## Datasets for sensitivity analyses ################################################## ### without Dropouts ### table(dat0$dropout) dat2 <- subset(dat0, select = c(dropout, study_center, Sex, Age, CASMIN, migration, Personshousehold, proxy, Pre_fracture_dependency, Fracture_type, Charlson_commorbity_index_cat, polypharmacy, Social_support, subjective_need, Surgery, ICU_episode, Referral_to_rehabilitation_facility, Malnutrition, PHQ_4_cat, OHS, EQ5Dindex_diff, vas_diff, EQ5Dindex, EQ5Dindex_FU, vas_retro_bl, vas_today_a)) dat_withoutDropout <- dat2[dat2$dropout=="No dropout",] dat_withoutDropout <- subset(dat_withoutDropout, select = c(study_center, Sex, Age, CASMIN, migration, Personshousehold, proxy, Pre_fracture_dependency, Fracture_type, Charlson_commorbity_index_cat, polypharmacy, Social_support, subjective_need, Surgery, ICU_episode, Referral_to_rehabilitation_facility, Malnutrition, PHQ_4_cat, OHS, EQ5Dindex_diff, vas_diff, EQ5Dindex, EQ5Dindex_FU, vas_retro_bl, vas_today_a)) ### only patients age 65+ ### dat_65 <- dat1[dat1$Age>64,]