R/download_col_china.R

Defines functions download_col_china

Documented in download_col_china

#' @title Download 'Catalogue of Life China': Annual Checklist
#' @description  Organized by the Biodiversity Committee of Chinese Academy of Sciences (BC-CAS), Catalogue of Life China Annual Checklist edition has been compiled by Species 2000 China Node.
#' @rdname download_col_china
#' @name download_col_china
#' @param version \code{integer} Release version of annual checklist,the default value is 2020.
#' @param OS \code{character} Supported operating system,c("MacOS", "Ubuntu" ,"Windows"),the default value is "MacOS".
#' @param dir A non-empty character vector giving the directory name by user,the default value is dir = tempdir(),see \code{\link{tempdir}} for details.
#' @param mode A character string specifying the mode with which to write the file. Useful values are "w", "wb" (binary), "a" (append) and "ab". see \code{\link{download.file}} for details.
#' @param ... Allow additional arguments to be passed, unused. see \code{\link{download.file}} for details.
#' @return URL
#' @author Liuyong Ding \email{ly_ding@126.com}
#' @details Visit the website \url{http://sp2000.org.cn/download} for more details.
#' @importFrom utils download.file
#' @importFrom utils browseURL
#' @examples
#' \dontrun{
#' dir <- tempdir()
#' download_col_china(version = "2020",OS = "MacOS", dir = dir)
#' }
#' @export
download_col_china <- function(version = "2020", OS = "MacOS", dir = tempdir(), mode, ...) {
  cat(sprintf("Download date: %s",Sys.Date()),sep = "\n")
  version <- match.arg(version, 2018:as.integer(substr(Sys.Date(), 1, 4)))
  OS <- match.arg(OS, c("MacOS", "Ubuntu" ,"Windows"))
  if (version %in% c("2018","2019") ){
    url <- paste0('http://sp2000.org.cn/CoL/CoLChina',version, '.',"iso")
  }
  if (version == "2020" & OS == "MacOS"){
    url <- paste0('http://sp2000.org.cn/CoL/CoLChina',version,"-v20.1.12_mac_64", '.',"iso")
  }
  if (version == "2020" & OS == "Ubuntu"){
    url <- paste0('http://sp2000.org.cn/CoL/CoLChina',version,"-v20.1.12_linux_64", '.',"iso")
  }
  if (version == "2020" & OS == "Windows"){
    url <- paste0('http://sp2000.org.cn/CoL/CoLChina',version,"-v20.1.12_win_x86_64", '.',"iso")
  }
  outfile <- sub(".*/", "", url)
  download.file(url, file.path(dir,outfile),mode, ...)
  cat(sprintf("Download path: %s",dir),sep = "\n")
  browseURL(url)
}

Try the SP2000 package in your browser

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

SP2000 documentation built on Nov. 8, 2020, 4:41 p.m.