Skip to content

Commit

Permalink
add adjustments. Still not figures
Browse files Browse the repository at this point in the history
  • Loading branch information
caitobrien committed Nov 28, 2023
1 parent 868f69a commit a8aedf6
Show file tree
Hide file tree
Showing 7 changed files with 3,818 additions and 26 deletions.
49 changes: 25 additions & 24 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,47 @@ app_ui <- function(request) {
# select species of interest
selectInput(inputId = "select_spp",
label = "Select species",
choices = c("Chinook (CH)", "Steelhead (STL)"),
selected = NULL,
choices = data$species,#c("Chinook (CH)", "Steelhead (STL)"),
selected = NULL,#"Chinook (CH)",
width = "200px",
multiple = T),
#select rear type
selectInput(inputId = "select_rear",
label = "Select rearing type",
choices = c("Wild (W)", "Hatchery (H)"),
selected = NULL,
width = "200px",
multiple = T),
# select response metric
selectInput(inputId = "select_metric",
label = "Select response metric",
choices = c("Smolt-to-adult return ratio (SAR) ", " Transport to bypass ratio (T:B)"),
selected = NULL,
choices = data$rear_type, #c("Wild (W)", "Hatchery (H)"),
selected = NULL, #"Wild (W)",
width = "200px",
multiple = T),
# # select response metric
# selectInput(inputId = "select_metric",
# label = "Select response metric",
# choices = c("Smolt-to-adult return ratio (SAR) ", " Transport to bypass ratio (T:B)"),
# selected = "Smolt-to-adult return ratio (SAR) ",
# width = "200px",
# multiple = T),
# select covariate of interest
selectInput(inputId = "select_cov",
label = "Select covariate",
choices = c("Day of Year (DOY)", "Temperature"),
selected = NULL,
choices = data$covariate, #c("Day of Year (DOY)", "Temperature"),
selected = NULL, #"Day of Year (DOY)",
width = "200px",
multiple = T),
# select years of interest
# select years of interest--currently able to select one year based on function writtten-UPDATE
shinyWidgets::pickerInput(inputId = "select_year",
label = "Select years",
choices = 1993:2018,
choices = unique(data$year),#1993:2018,
selected = NULL, #1993:2018,
options = list(`actions-box` = TRUE),
width = "200px",
multiple = T), #windowPadding = 1 doesn't work
# add button to run after options are selected
actionButton(inputId = 'btn_run_selected',
label = paste0('Run'),
icon = icon("wrench")),
## reset side bar selectoin
actionButton(inputId = 'btn_reset_selected',
label = 'Reset',
icon = icon('refresh') )
multiple = T) #windowPadding = 1 doesn't work
# # add button to run after options are selected
# actionButton(inputId = 'btn_run_selected',
# label = paste0('Run'),
# icon = icon("wrench")),
# ## reset side bar selectoin
# actionButton(inputId = 'btn_reset_selected',
# label = 'Reset',
# icon = icon('refresh') )

),

Expand Down
8 changes: 8 additions & 0 deletions R/fct_get_pred_data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#' get_pred_data
#'
#' @description A fct function
#'
#' @return The return value, if any, from executing the function.
#'
#' @noRd

36 changes: 36 additions & 0 deletions R/fct_make_plots.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#' make_plots
#'
#' @description A fct function
#'
#' @return The return value, if any, from executing the function.
#'
#' @noRd


plot_fx<- function(spp, rtype, cov, SAR_year){
data %>%
filter(year == SAR_year,
species == spp,
rear_type == rtype,
covariate == cov) %>%
ggplot(aes( x= date, color = as.factor(transport), group = year)) +
geom_point(aes(y =SAR, fill = as.factor(transport)))+
geom_jitter(aes(y =sar.pit, shape = as.factor(transport)), alpha = .7)+
geom_lineribbon( aes(y = SAR, ymin =SAR.lo, ymax = SAR.hi, fill = as.factor(transport)), alpha = .25) +
labs( x = "Date", y = "SAR", color = NULL,
fill = NULL, shape = NULL,
title = "Predicted SAR versus observed SAR from PIT tag recoveries",
subtitle = paste("Year:",SAR_year)) +
scale_color_manual(breaks = c(0, 1),
values = c("steelblue4", "#b47747"),
labels = c("In-river, \npredicted with 95% CI", "Transported, \npredicted with 95% CI"))+
scale_fill_manual(breaks = c(0, 1),
values = c("steelblue4", "#b47747"),
labels = c("In-river, \npredicted with 95% CI", "Transported, \npredicted with 95% CI"))+
scale_shape_manual(values = c(21,21),
breaks = c(0,1),
labels = c("In-river, observed", "Transported, observed")) +
guides(shape = "legend") +
theme_minimal()

}
52 changes: 50 additions & 2 deletions R/mod_Figures.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Home UI Function
#' Figures UI Function
#'
#' @description A shiny Module.
#'
Expand All @@ -11,17 +11,65 @@ mod_Figures_ui <- function(id){
ns <- NS(id)
tagList(

fluidPage(

fluidRow(
h2("Header"),
shinydashboard::box(
title = "X",
width = 6,
plotOutput(outputId = ns("plot1"))),

shinydashboard::box(
title = "X2",
width = 6,
plotOutput(outputId = ns("plot2"))
)
),

fluidRow(
shinydashboard::box(
title = "X",
width = 6,
plotOutput(outputId = ns("plot3"))),

shinydashboard::box(
title = "X2",
width = 6,
plotOutput(outputId = ns("plot4"))
)
)
)
)
}

#' Home Server Functions
#' Figures Server Functions
#'
#' @noRd
mod_Figures_server <- function(id){
moduleServer( id, function(input, output, session){
ns <- session$ns

plot1 <- reactive({plot_fx(spp = input$select_spp,
rtype = input$select_rear,
cov = input$select_cov,
SAR_year = input$select_year)})
output$plot1 <- renderPlot({
plot1()
})

output$plot2 <- renderPlot({
shinipsum::random_ggplot(type = "line")
})

output$plot3 <- renderPlot({
shinipsum::random_ggplot(type = "line")
})

output$plot4 <- renderPlot({
shinipsum::random_ggplot(type = "line")
})

})
}

Loading

0 comments on commit a8aedf6

Please sign in to comment.