Hi,
I've read in various places that using &
and |
within for
statements should not really work. For example, as illustrated here. However, I have a bit of code for my shinyapps here:
`
bridgingTable <- reactive({
if(input$thromRisk == "High" & input$gfr >= 30){
bridge <- BrHighRisk
# To sort out the Date and Weekday Columns
opdate <- as.Date(input$OpDate)
dates <- as.Date(c(opdate - 6, opdate - 5, opdate - 4, opdate -3, opdate - 2, opdate - 1, opdate, opdate + 1, opdate + 2))
dates_chr <- format(as.Date(c(opdate - 6, opdate - 5, opdate - 4, opdate -3, opdate - 2, opdate - 1, opdate, opdate + 1, opdate + 2)), "%d/%m/%y")
dates_chr <- as.character(dates_chr)
bridge$Date <- dates_chr
wdays <- weekdays(dates)
bridge$Weekday <- wdays
if(input$weight <= 46){
bridge <- bridge %>%
select(Day, Date, Weekday, Warfarin, "INR Check" = INR, "Dalteparin Treatment" = TxDose_1, "Dalteparin Prophylaxis*" = Prophylaxis_1)
}else if(input$weight > 46 & input$weight < 57){
if(input$weight < 50){
bridge <- bridge %>%
select(Day, Date, Weekday, Warfarin, "INR Check" = INR, "Dalteparin Treatment" = TxDose_2, "Dalteparin Prophylaxis*" = Prophylaxis_1)
}else if(input$weight >= 50 & input$weight < 100){
bridge <- bridge %>%
select(Day, Date, Weekday, Warfarin, "INR Check" = INR, "Dalteparin Treatment" = TxDose_2, "Dalteparin Prophylaxis*" = Prophylaxis_2)
}
}else if(input$weight >= 57 & input$weight < 69){
bridge <- bridge %>%
select(Day, Date, Weekday, Warfarin, "INR Check" = INR, "Dalteparin Treatment" = TxDose_3, "Dalteparin Prophylaxis*" = Prophylaxis_2)
}else if(input$weight >= 69 & input$weight < 83){
bridge <- bridge %>%
select(Day, Date, Weekday, Warfarin, "INR Check" = INR, "Dalteparin Treatment" = TxDose_4, "Dalteparin Prophylaxis*" = Prophylaxis_2)
}else if(input$weight >= 83 & input$weight < 100){
bridge <- bridge %>%
select(Day, Date, Weekday, "Warfarin Dose" = Warfarin, "INR Check" = INR, "Dalteparin Treatment" = TxDose_5, "Dalteparin Prophylaxis*" = Prophylaxis_2)
}else if(input$weight >= 100 & input$weight < 150){
bridge <- bridge %>%
select(Day, Date, Weekday, "Warfarin Dose" = Warfarin, "INR Check" = INR, "Dalteparin Treatment" = TxDose_5, "Dalteparin Prophylaxis*" = Prophylaxis_3)
}else if(input$weight >= 150){
bridge <- bridge %>%
select(Day, Date, Weekday, "Warfarin Dose" = Warfarin, "INR Check" = INR, "Dalteparin Treatment" = TxDose_5, "Dalteparin Prophylaxis*" = Prophylaxis_4)
}
}else if(input$thromRisk == "Moderate" & input$gfr >= 30){
bridge <- BrModRisk
`
This seems to work okay without any errors being generated when it runs.
I guess I shouldn't really question why something would work but I am just a bit puzzled and wouldn't mind some explanation as I am still relatively new to coding.
KR,
L