toString.Rd 1.6 KB
Newer Older
Radford Neal's avatar
Radford Neal committed
1 2
% File src/library/base/man/toString.Rd
% Part of the R package, http://www.R-project.org
3
% Copyright 1995-2007 R Core Team
Radford Neal's avatar
Radford Neal committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
% Distributed under GPL 2 or later

\name{toString}
\alias{toString}
\alias{toString.default}

\title{Convert an R Object to a Character String}
\description{
  This is a helper function for \code{\link{format}} to produce a single
  character string describing an \R object.
}
\usage{
toString(x, \dots)

\method{toString}{default}(x, width = NULL, \dots)
}
\arguments{
  \item{x}{The object to be converted.}
  \item{width}{Suggestion for the maximum field width.  Values of
    \code{NULL} or \code{0} indicate no maximum.
    The minimum value accepted is 6 and smaller values are taken as 6.}
  \item{\dots}{Optional arguments passed to or from methods.}
}
\details{
  This is a generic function for which methods can be written: only the
  default method is described here.  Most methods should honor the
  \code{width} argument to specify the maximum display width (as measured
  by \code{\link{nchar}(type = "width")} of the result.

  The default method first converts \code{x} to character and then
  concatenates the elements separated by \code{", "}.
  If \code{width} is supplied and is not \code{NULL}, the default method
  returns the first \code{width - 4} characters of the result with
  \code{....} appended, if the full result would use more than
  \code{width} characters.
}
\value{
  A character vector of length 1 is returned.
}
\author{ Robert Gentleman }

\seealso{ \code{\link{format}} }

\examples{
x <- c("a", "b", "aaaaaaaaaaa")
toString(x)
toString(x, width=8)
}
\keyword{utilities}