Skip to content

Commit

Permalink
Add logic for all-cause-mortality. Fix #25
Browse files Browse the repository at this point in the history
  • Loading branch information
usr110 committed Oct 4, 2021
1 parent 4bb20f4 commit 156b7d2
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,34 @@ shinyServer(function(input, output, session){

# Add additional "fatal" studies that had no "both" types
if (local_outcome_type == "Fatal-and-non-fatal") {

# Subset fatal types
add_fdata <- subset(raw_data_tp_ltpa, outcome == local_outcome &
pa_domain_subgroup == local_pa_domain_subgroup &
outcome_type == "Fatal")

# Subset Non-fatal types
add_nfdata <- subset(raw_data_tp_ltpa, outcome == local_outcome &
pa_domain_subgroup == local_pa_domain_subgroup &
outcome_type == "Non-fatal")

# ONLY add those studies that have no "both" studies
add_fdata <- subset(add_fdata, !id %in% acmfdata$id)
# ONLY add those studies that have no "both" studies
add_nfdata <- subset(add_nfdata, !id %in% acmfdata$id)

# Add logic to return an empty data frame when Fatal-and-non-fatal and Non-fatal are both empty. Solves #25 issue
if (nrow(acmfdata) == 0 && nrow(add_nfdata) == 0){
return(data.frame())
}

# Add additional rows
if (nrow(add_fdata) > 0) {
# if (nrow(acmfdata) == 0)
# next()
acmfdata <- rbind(acmfdata, add_fdata)
}

# Subset Non-fatal types
add_nfdata <- subset(raw_data_tp_ltpa, outcome == local_outcome &
pa_domain_subgroup == local_pa_domain_subgroup &
outcome_type == "Non-fatal")

# ONLY add those studies that have no "both" studies
add_nfdata <- subset(add_nfdata, !id %in% acmfdata$id)
# Add additional rows
if (nrow(add_nfdata) > 0) {
acmfdata <- rbind(acmfdata, add_nfdata)
Expand Down

0 comments on commit 156b7d2

Please sign in to comment.