R/import.R

Defines functions import

Documented in import

#' Import Data
#'
#' Read data from clipboard.
#'
#' @param header passed to \code{read.table}.
#' @param \dots passed to \code{read.table}.
#'
#' @return Vector or data frame from clipboard.
#'
#' @note
#' Data are read from the clipboard using \code{read.table}, and then converted
#' to a vector if the data are in a single row or single column.
#'
#' @importFrom utils read.table
#'
#' @export

import <- function(header=FALSE, ...)
{
  ## Suppress warning about incomplete final line
  x <- suppressWarnings(read.table("clipboard", header=header, ...))

  if(nrow(x)==1 || ncol(x)==1)
    x <- unname(unlist(x))

  x
}
arni-magnusson/arni documentation built on Nov. 3, 2023, 7:35 p.m.