R/defineSelected.R

Defines functions defineSelected

Documented in defineSelected

#' Define Selected Text
#'
#' Detects a selected word in an open document. This was tested for Rmarkdown writing, but it can be used for an open document.
#' Using the addin is the most preferred means to call this function, albeit it can be called directly from the console.
#'
#' @return definition of the selected text
#' @examples
#' \dontrun{
#' defineSelected()
#' }
#' @export
#'
#'

defineSelected <-function(){
  #fetch selected term
  the.selected <- fetchSelectedText()

  #if selected term is present and contains alphabets, find definition. else, yell at the user
  if(the.selected[1]){
    define(the.selected[2])
  }
  else{
    message("No words selected within the current document.")
  }
}

#' Define Selected Text
#'
#' Detects a selected word in an open document. This was written for Rmarkdown writing, but it can be used for an open document.
#' Using the addin is the most preferred means to call this function, albeit it can be called directly from the console.
#'
#' @return definition of the selected text
#' @examples
#' \dontrun{
#' defineSel()
#' }
#' @export
#'
#'

defineSel <- defineSelected

Try the r2dictionary package in your browser

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

r2dictionary documentation built on July 26, 2023, 5:34 p.m.