Commit 1e599f0b authored by levintow's avatar levintow
Browse files

updating code with lowercase variable names

parent d96c8fea
......@@ -15,21 +15,21 @@ devtools::use_data(wihs)
use_data_raw()
# Load R data set
load(file="wihs.Rda")
load(file="data/wihs.Rda")
# Initial analyses looking at data
library(ggplot2)
library(dplyr)
library(survival)
table(w$IDU,w$DELTA,useNA = "always")
review<-w %>%
group_by(IDU) %>%
summarize(num=n(),outcome=mean(DELTA),dropout=mean(DROP),time=mean(T))
table(w$idu,w$delta,useNA = "always")
review<-wihs %>%
group_by(idu) %>%
summarize(num=n(),outcome=mean(delta),dropout=mean(drop),time=mean(time))
# Crude survival analysis
w$SurvObj <- with(w, Surv(T, DELTA == 1))
head(w)
wihs$SurvObj <- with(wihs, Surv(time, delta == 1))
head(wihs)
# Kaplan-Meier estimator
km.as.one <- survfit(SurvObj ~ 1, data = w)
km.by.IDU <- survfit(SurvObj ~ IDU, data = w)
km.as.one <- survfit(SurvObj ~ 1, data = wihs)
km.by.idu <- survfit(SurvObj ~ idu, data = wihs)
# Basic plots
plot(km.as.one)
plot(km.by.IDU)
plot(km.by.idu)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment