R/WhistlerUsersGuide.R

Defines functions WhistlerUsersGuide

Documented in WhistlerUsersGuide

#' @title  View WhistleR User's Guide
#' @description 
#' Finds the location of the WhistleR User's Guide and optionally opens it.
#' @param view logical, should the document be opened using the default PDF document reader?
#' @details 
#' The function vignette("WhistleR") will find the short WhistleR Vignette which describes how to obtain the WhistleR User's Guide. The User's Guide is not itself a true vignette because it is not automatically generated using \link{Sweave} during the package build process. This means that it cannot be found using vignette, hence the need for this special function.
#' If the operating system is other than Windows, then the PDF viewer used is that given by Sys.getenv("R_PDFVIEWER"). The PDF viewer can be changed using Sys.putenv(R_PDFVIEWER=).
#' @return Character string giving the file location. If view=TRUE, the PDF document reader is started and the User's Guide is opened, as a side effect.
#' @author Zhen Wei
#' @seealso \link{system}
#' @examples 
#' \dontrun{
#' # To get the location:
#' WhistlerUsersGuide(view=FALSE)
#' # To open in pdf viewer:
#' WhistlerUsersGuide()
#' }
#' @export
WhistlerUsersGuide <- function(view = TRUE){
  f <- system.file("doc", "WhistlerUsersGuide.pdf", package = "WhistleR")
  if (view) {
    if (.Platform$OS.type == "windows") 
      shell.exec(f)
    else system(paste(Sys.getenv("R_PDFVIEWER"), f, "&"))
  }
  return(f)
}
ZW-xjtlu/WhistleR documentation built on March 13, 2021, 10:50 a.m.