R/fct_tab_op_points.R

Defines functions tab_op_points

Documented in tab_op_points

#' Output DT data table of operation points
#'
#' @param op_data Calculated Operations points Table
#'
#' @return DTtable
#' @export
#'
#' @examples
#' op_data <- tibble::tibble(p1 = c(2,3), p2 = c(1,1), flow = c(500, 750))
#' op_data <- operation_points(op_data, "VAG", "E", 200)
#' tab_op_points(op_data)

tab_op_points <- function(op_data) {

  position <- cav_regime <-  NULL
  op_data %>%
    dplyr::mutate(position = position/100) %>%
    # https://rstudio.github.io/DT/
    DT::datatable(caption  = "Operations Data:",
                  editable = FALSE,
                  class    = "hover cell-border stripe",
                  colnames = c('P1 (Bar)', 'P2 (Bar)', 'Flow (m3/h)', 'Vel. (m/s)',
                               'Pos. (%)', 'Kv (m3/h)', 'Zeta (-)', 'Sigma (-)',
                               'cav_regime (-)'),
                  extensions = c('Buttons'),
                  options  = list(dom = 'Bt',
                                  buttons = c('copy', 'excel'))) %>%
    DT::formatPercentage(c('position'), 1) %>%
    DT::formatCurrency(c('flow', 'velocity', 'kv'), currency = "", interval = 3, mark = ",", digits= 1) %>%
    DT::formatCurrency(c('zv', 'sigma_value'), currency = "", interval = 3, mark = ",", digits= 2) %>%
    DT::formatStyle(
      'velocity',
      fontWeight      = DT::styleInterval(5, c('normal', 'bold')),
      color           = DT::styleInterval(5, c('black',  'red')),
      backgroundColor = DT::styleInterval(5, c('white',  'yellow'))
    ) %>%
    DT::formatStyle(
      'cav_regime',
      color = DT::styleEqual(c("Regime 3: Constant cavitation.",
                               "Regime 4: Maximum vibration cavitation."),
                             c('orange','red'))
    )
}
ratral/gpvapp documentation built on May 13, 2022, 12:51 a.m.