Last active
April 18, 2023 09:48
-
-
Save mzdravkov/b9f117c2ad2ca86f7d28c3de62799714 to your computer and use it in GitHub Desktop.
biostatistics_project.r
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dataset <- read.csv("Dataset.csv", stringsAsFactors=TRUE, header=TRUE) | |
Dataset <- Dataset[Dataset$Assignment != "",] | |
View(Dataset) | |
drugs <- data.frame( | |
Name = c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "AA", "AB", "AC", "AD"), | |
Color = c("Red", "Red", "Green", "Yellow", "Red", "Yellow", "Red", "Red", "Red", "Red", "Green", "Red", "Red", "Red", "Green", "Red", "Red", "Green", "Yellow", "Red", "Red", "Yellow", "Yellow", "Red", "Yellow", "Red", "Yellow", "Red", "Red", "Green") | |
) | |
red_cols <- drugs$Name[drugs$Color == "Red"] | |
yellow_cols <- drugs$Name[drugs$Color == "Yellow"] | |
green_cols <- drugs$Name[drugs$Color == "Green"] | |
Dataset$red = rowSums(Dataset[, red_cols]) | |
Dataset$yellow = rowSums(Dataset[, yellow_cols]) | |
Dataset$green = rowSums(Dataset[, green_cols]) | |
# Move "red" and "yellow" drugs to "green" for EG patients in both experimental and control groups | |
EG_patients <- Dataset$Therapeutic.Guidances == "EG" | |
Dataset[EG_patients, "green"] <- rowSums(Dataset[EG_patients, c("red", "yellow", "green")]) | |
Dataset[EG_patients, "red"] <- 0 | |
Dataset[EG_patients, "yellow"] <- 0 | |
# Move "yellow" drugs to "green" for CT patients in the experimental group | |
# (we have CT only in experimental group) | |
CT_patients <- Dataset$Therapeutic.Guidances == "CT" | |
Dataset[CT_patients, "green"] <- rowSums(Dataset[CT_patients, c("yellow", "green")]) | |
Dataset[CT_patients, "yellow"] <- 0 | |
linear_model <- lm(LOS ~ GENDER + AGE + RACE.ETHNICITY + MD + Assignment + Therapeutic.Guidances + red + yellow + green, data=Dataset) | |
summary(linear_model) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment