Skip to content

Instantly share code, notes, and snippets.

@MJacobs1985
Created November 9, 2022 15:45
Show Gist options
  • Save MJacobs1985/04e1caf86e1ecb6e4e570f9a9c852e4f to your computer and use it in GitHub Desktop.
Save MJacobs1985/04e1caf86e1ecb6e4e570f9a9c852e4f to your computer and use it in GitHub Desktop.
pancreas$Performance_status_at_consultation<-factor(pancreas$Performance_status_at_consultation)
pancreas$Performance_status_at_consultation
pancreas$Gender<-factor(pancreas$Gender,
levels = c("1", "2"),
labels = c("Female", "Male"))
pancreas$Gender
pancreas$Disease_stage_at_consultation<-factor(pancreas$Disease_stage_at_consultation,
levels = c("1", "2"),
labels = c("Metastasized", "Non-Metastasized"))
pancreas$Disease_stage_at_consultation
pancreas$Tumorsite_in_pancreas<-factor(pancreas$Tumorsite_in_pancreas,
levels = c("1", "2","3"),
labels = c("Head", "Body", "Tail"))
pancreas$Tumorsite_in_pancreas
pancreas$Non_opioid_spec<-factor(pancreas$Non_opioid_spec,
levels = c("1", "2","3"),labels = c("pcm", "NSAID", "other"))
pancreas$Non_opioid_spec
pancreas$Opioid_spec<-factor(pancreas$Opioid_spec,
levels = c("1", "2","3"),labels = c("Pleister", "Oral", "other"))
pancreas$Opioid_spec
pancreas$Surgery_prior_to_consultation <- as.factor(pancreas$Surgery_prior_to_consultation);pancreas$Surgery_prior_to_consultation
pancreas$Chemotherapy_prior_to_consultation <- as.factor(pancreas$Chemotherapy_prior_to_consultation);pancreas$Chemotherapy_prior_to_consultation
pancreas$Non_opioids_YN <-as.factor(pancreas$Non_opioids_YN);pancreas$Non_opioids_YN
pancreas$datum_dead<-dmy(pancreas$datum_dead)
class(pancreas$datum_dead)
pancreas$datum_dead
pancreas$Date_intake<-dmy(pancreas$Date_intake) class(pancreas$Date_intake)
pancreas$Date_intake
pancreas$SurvTime<-pancreas$datum_dead-pancreas$Date_intake; class(pancreas$SurvTime)
pancreas$SurvTime
pancreas$Event<-ifelse(!is.na(pancreas$SurvTime), 1, 0)
pancreas$Event
pancreas$SurvTime<-ifelse(pancreas$Event==0,
as.Date('20/09/21',format='%d/%m/%y') pancreas$Date_intake,pancreas$SurvTime)
pancreas$SurvTime
ggplot(pancreas, aes(x=SurvTime)) + geom_density(color="darkblue", fill="lightblue")+theme_bw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment