R/utils.R

Defines functions docker_image compatibility_table supported_Rs supported_platforms

Documented in compatibility_table docker_image supported_platforms supported_Rs

#' Return supported platforms
#'
#' Return list of supported platforms with their key to access.
#' @export
#' @examples
#' library("altRnative")
#' supported_platforms()
supported_platforms <- function(){
  return(
    list(
      ("debian" = "Debian Linux"),
      ("fedora" = "Fedora Linux"),
      ("archlinux" = "Arch Linux")
    )
  )
}


#' Return supported R implementations
#'
#' Return list of supported R implementations with their key to access.
#' @export
#' @examples
#' library("altRnative")
#' supported_Rs()
supported_Rs <- function(){
  return(
    list(
      ("gnu-r" = "GNU R"),
      ("mro" = "Microsoft R Open"),
      ("renjin" = "Renjin"),
      ("fastr" = "FastR"),
      ("pqr" = "pqR"),
      ("terr" = "TERR")
    )
  )
}
#' Return a compatibility table
#'
#' Return a table that consist of platfom, R implementation, docker image name.
#' @import dplyr
#' @export
#' @examples
#' compatibility_table()
compatibility_table <- function(){
  tibble(
    dist = c("debian", "ubuntu"),
    R = c("gnu-r", "mro"),
    image_name = c("ismailsunni/gnur-3.6.1-debian-geospatial", "ismailsunni/mro-3.5.3-ubuntu-geospatial"))
}

#' Get docker image for a combination of a platform and a R implementation.
#'
#' Return the name of docker image. Return empty string if the combination is not supported.
#' @import dplyr
#' @param platform The platform name see \link{supported_platforms}
#' @param r_implementation The R implementation name. See \link{supported_Rs}
#' @export
#' @examples
#' library("altRnative")
#' docker_image("debian", "gnu-r")
#' docker_image("ubuntu", "mro")
#' docker_image("debian", "renjin")
docker_image <- function(platform = "debian", r_implementation = "gnu-r"){
  table <- compatibility_table()
  result <- dplyr::filter(table, dist == platform, R == r_implementation)
  return(pull(result, "image_name"))
}
ismailsunni/altRnative documentation built on Dec. 9, 2019, 6:35 p.m.