knitr::opts_chunk$set(echo = TRUE)

my.prn

my.prn <-
function (x, txt) 
{
    calltext <- as.character(sys.call())[2]
    if (!missing(txt)) {
        if (nchar(txt) + nchar(calltext) + 3 > .Options$width) 
            calltext <- paste("\n\n ", calltext, sep = "")
        else txt <- paste(txt, " ", sep = "")
        cat("\n", txt,"\n> " ,calltext, "\n\n", sep = "")
    }
    else cat("\n> ", calltext, "\n\n", sep = "")
    invisible(print(x))
}
#' @examples
my.prn(1:5)
my.prn(1:5,"This is a sequence of first five integers")
my.prn(exists("bla"),"You can check, if object named bla exists")

read.clipboard

This works only on Windows

# ------------------------------------------------------------
#' Read Clipboard
#'
#' Read text (usually table with data) from clipboard. This is a wrapper function for \code{read.table} with different defaults.
#'
#' @param header
#' a logical value indicating whether the file contains the names of the variables as its first line. Defaults to \code{TRUE}. If missing, the value is determined from the file format: header is set to TRUE if and only if the first row contains one fewer field than the number of columns.
#' @param sep
#' the field separator character (default \code{\\t}).
#' Values on each line of the file are separated by this character.
#' If sep = "" (the default for read.table) the separator
#' is 'white space', that is one or more spaces, tabs, newlines or carriage returns.
#' @param ... additional arguments passed to \link{read.table}.
#' @return A data frame. See \link{read.table}
#' @export
#' @importFrom utils read.table
#' @seealso \link{read.table}.
#' @author Andrej Blejec \email{andrej.blejec@nib.si}
#' @examples \dontrun{
#' # Copy some data to clipboard before running this code
#' read.clipboard()
#' }
read.clipboard <-
  function (header = T, sep = "\t", ...) {
    read.table (file = "clipboard", header = header, sep = sep, ...)
  }


ablejec/amisc documentation built on May 10, 2019, 4:13 a.m.