Skip to content

Commit

Permalink
- Changing the input style from the original matrix input to the nume…
Browse files Browse the repository at this point in the history
…ric input icon

- Easier to validate
  • Loading branch information
Songyosr committed Feb 22, 2023
1 parent 00fd3f8 commit ff415ee
Show file tree
Hide file tree
Showing 4 changed files with 323 additions and 136 deletions.
39 changes: 39 additions & 0 deletions helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ library(tidyverse)
library(shiny)
library(shinyMatrix)
library(shinyvalidate)
library(shinyWidgets)
library(plotly)
library(reactable)

Expand Down Expand Up @@ -50,6 +51,44 @@ check_point <- function(condition, msg = NULL, h = 1, n =1) {
}
# check_point(1,"print"); check_point(1,"subprint", 2);check_point(1)

## Utility function
# set limit ------
set_limit <- function(outcome = "Mean", method = "direct"){
if(outcome == "Mean" | method == "oddsRatio"){
return(c('min' = -Inf, "max" = Inf))
} else if(method == "relative") {
return(c('min' = 0, "max" = Inf))
} else {
base <- c(-1*(method != "direct") ,1)
times <- ifelse(outcome != "Incidence Rate", 1, Inf)
tmp <- base*times
tmp[is.nan(tmp)] <- 0
setNames(tmp, c('min', 'max'))
}
}

# set_icon -----
# Function to set icon for each type of method
set_icon <- function(method){
case_when(
method == "direct" ~ list(icon("people-group")),
method == "absolute" ~ list(icon("plus-minus")),
method == "relative" ~ list(icon("divide")),
TRUE ~ list(icon("question"))
)
}

# Example for set_* ----
# mt <- c("direct", "absolute", "relative")
# oc <- c("Mean", "Proportion", "Incidence Rate")
# test_dt <- expand_grid(mt, oc)
# test_dt %>% rowwise() %>%
# mutate(min_max = paste(set_limit(oc, mt), collapse = ","),
# icons = set_icon(mt)) %>%
# pivot_wider(names_from = oc, values_from = c(min_max, icons))



# SS_calculation2 ------
# Function to calculate the sample size required
SS_calculation2 <- function(outcome = c("Proportion", "Mean", "Incidence Rate"),
Expand Down
10 changes: 5 additions & 5 deletions rsconnect/shinyapps.io/songyosr/Sample_Size.dcf
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Sample_Size
title: Sample_Size
title:
username:
account: songyosr
server: shinyapps.io
hostUrl: https://api.shinyapps.io/v1
appId: 8353730
bundleId: 6869147
bundleId: 6870890
url: https://songyosr.shinyapps.io/Sample_Size/
when: 1676961251.58897
lastSyncTime: 1676961251.58898
when: 1677000386.59337
lastSyncTime: 1677000386.59338
asMultiple: FALSE
asStatic: FALSE
ignoredFiles: .RData|fig/example_v0.1.0_alpha.gif|README.html|README.md|tests/shinytest.R|del
ignoredFiles: .RData|fig/example_v0.1.0_alpha.gif|LICENSE|README.html|README.md|tests/shinytest.R|del
Loading

0 comments on commit ff415ee

Please sign in to comment.