R/showmekittens.R

Defines functions showmekittens

Documented in showmekittens

#' When you need a break...
#'
#' Genetic data analysis can be a harsh, tiring, daunting task.
#' Sometimes, a mere break will not cut it.
#' Sometimes, you need a kitten.
#'
#' @author Thibaut Jombart \email{thibautjombart@@gmail.com}
#'
#' @export
#'
#' @details
#'
#' Please send us more! Either pull request or submit an issue with a URL (use
#' \code{adegenetIssues()}).
#'
#'
#' @param x the name or index of the video to display; if NULL, a random video is chosen
#'
#' @param list a logical indicating if the list of available videos should be displayed
#'
showmekittens <- function(x = NULL, list = FALSE){
    ## 'pool' is a named character vector of video URLs
    pool <- c(capucine = "http://www.youtube.com/watch?v=KIePsbJSS04",
              vacuum = "https://www.youtube.com/watch?v=9J4UKYm9320",
              eclipse = "https://www.youtube.com/watch?v=RsUH2MuY33o",
              nom     = "https://www.youtube.com/watch?v=Cl5Pfc5TyO0",
              knockdown = "https://www.youtube.com/watch?v=izRZxhqfk0Y",
              Tedders = "https://www.youtube.com/watch?v=2J1ynsuWcNQ",
              deepvoice = "https://www.youtube.com/watch?v=w7x_lWJNnNg",
              goblin = "https://www.youtube.com/watch?v=LtNrf4wsy_U",
              duettocatti = "https://www.youtube.com/watch?v=gMdn0ezJxUE",
              blackjaguar = "https://www.youtube.com/watch?v=UdwRo9wfKmc",
              heySOUP = "https://www.youtube.com/watch?v=JQo3ZOO6FG4",
              noisyboy = "https://www.youtube.com/watch?v=FjY-6usXzgg",
              honking = "https://www.youtube.com/watch?v=omTE4iM7pTA",
              curiouskitten = "https://www.youtube.com/watch?v=AYYwM6aNegs",
              wheresthebabies = "https://www.youtube.com/watch?v=2rELs4jl64k",
              stayinalive = "https://www.youtube.com/watch?v=69SzfigTO7M",
              treadmill = "https://www.youtube.com/watch?v=i0sb0K7UPeU",
              leapfrog = "https://www.youtube.com/watch?v=RqA0SszVOcc",
              balloons = "https://www.youtube.com/watch?v=MSkDGa9Ei4U")

    ## either we return the list of videos, or we show one
    if (list) {
        return(pool)
    }

    if (is.null(x)) {
        x <- sample(seq_along(pool), 1L)
    }

    ## check that x is okay
    if (is.numeric(x) && (x < 1 || x > length(pool))) {
        stop(sprintf("Video index (%d) is wrong; there are currently %d videos in the list", x, length(pool)))
    }

    if (is.character(x) && !x %in% names(pool)) {
        stop(sprintf("Video name (%s) is not in the list; use the option 'list=TRUE' to see available videos.", x))
    }

    browseURL(pool[x])
}

Try the adegenet package in your browser

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

adegenet documentation built on Feb. 16, 2023, 6 p.m.