R/get_selectBy.R

Defines functions get_selectBy

get_selectBy <- function(selectBy = NULL, loonWidgetsInfo){
  
  selectBy <- if(is.null(selectBy)) {
    "sweeping" # default setting
  } else {
    if(!selectBy %in% c("byDefault", "brushing", "sweeping")) stop("selectBy must be one of `byDefault`, `brushing` and `sweeping`") else selectBy[1]
  }
  
  n <- length(loonWidgetsInfo)
  
  if(selectBy == "byDefault") {
    
    selectBy <- names(
      sort(
        table(
          unlist(
            lapply(1:n,
                   function(i) {
                     loonWidgetsInfo[[i]]$selectByLoon
                   })
          )
        ),decreasing=TRUE
      )[1]
    )
    
    if(is.null(selectBy)) selectBy <- "sweeping" 
  }
  
  selectBy
}

Try the loon.shiny package in your browser

Any scripts or data that you put into this service are public.

loon.shiny documentation built on Oct. 8, 2022, 5:05 p.m.