library(twang) star<- stardata names(star) summary(star) #recode gender star$Gender[star$Gender=="M"] <- 1 star$Gender[star$Gender=="F"] <- 2 #recode race star$Race[star$Race=="White"] <- 1 star$Race[star$Race=="Black"] <- 2 star$Race[star$Race=="Asian"] <- 3 star$Race[star$Race=="Native American"] <- 4 star$Race[star$Race=="Pacific Islander"] <- 5 star$Race[star$Race=="Multi-racial"] <- 6 #removing ID column star$`Deidentified Patient ID` <- NULL #omit null values star1<- na.omit(star) #write as csv write.csv(star1, file = "star_new.csv") #OMIT X1 column star_new$`X1` <- NULL star2<-star_new View(star2) star2$gender.f <- factor(star2$Gender) star2$race.f <- factor(star2$Race) names(star2) #recode the variable names star2$gen_anxiety_disorder<-star2$`Generalized Anxiety Diagnosis` star2$years_schooling_completed <- star2$`Years of schooling completed` star2$age_at_first_MDE <- star2$`Age at First MDE` star2$years_since_first_MDE <- star2$`Years Since First MDE` star2$ months_current_episode <- star2$`Months in current episode` star2$is_recurrent <- star2$`Is Recurrent` star2$family_depression <-star2$`Family Hx Depression` star2$family_bipolar<-star2$`Family Hx Bipolar` star2$panic<-star2$`Panic Diagnosis` star2$social_phobia<-star2$`Social Phobia Diagnosis` star2$OCD <-star2$`Obsessive Compulsive Diagnosis` star2$alcohol_abuse<-star2$`Alcohol Abuse Diagnosis` star2$drug_abuse <-star2$`Drug Abuse Diagnosis` star2$qids_score<-star2$`Drug Abuse Diagnosis` star2$hrsd_score<-star2$`HRSD-17 (ROA)` star2$cit_success<-star2$`CIT Success` ###################################################################