The R Project SVN R

Rev

Rev 68948 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/base/man/toString.Rd
68948 ripley 2
% Part of the R package, https://www.R-project.org
59039 ripley 3
% Copyright 1995-2007 R Core Team
42333 ripley 4
% Distributed under GPL 2 or later
5
 
11246 rgentlem 6
\name{toString}
56186 murdoch 7
\alias{toString}
11246 rgentlem 8
\alias{toString.default}
9
 
35279 ripley 10
\title{Convert an R Object to a Character String}
11246 rgentlem 11
\description{
35279 ripley 12
  This is a helper function for \code{\link{format}} to produce a single
13
  character string describing an \R object.
11246 rgentlem 14
}
15
\usage{
11402 ripley 16
toString(x, \dots)
25438 ripley 17
 
35279 ripley 18
\method{toString}{default}(x, width = NULL, \dots)
11246 rgentlem 19
}
20
\arguments{
11402 ripley 21
  \item{x}{The object to be converted.}
35279 ripley 22
  \item{width}{Suggestion for the maximum field width.  Values of
23
    \code{NULL} or \code{0} indicate no maximum.
32235 ripley 24
    The minimum value accepted is 6 and smaller values are taken as 6.}
35279 ripley 25
  \item{\dots}{Optional arguments passed to or from methods.}
11246 rgentlem 26
}
32235 ripley 27
\details{
35279 ripley 28
  This is a generic function for which methods can be written: only the
29
  default method is described here.  Most methods should honor the
30
  \code{width} argument to specify the maximum display width (as measured
74363 maechler 31
  by \code{\link{nchar}(type = "width")}) of the result.
35279 ripley 32
 
33
  The default method first converts \code{x} to character and then
34
  concatenates the elements separated by \code{", "}.
35
  If \code{width} is supplied and is not \code{NULL}, the default method
36
  returns the first \code{width - 4} characters of the result with
37
  \code{....} appended, if the full result would use more than
38
  \code{width} characters.
32235 ripley 39
}
11246 rgentlem 40
\value{
41
  A character vector of length 1 is returned.
42
}
43
\author{ Robert Gentleman }
44
 
45
\seealso{ \code{\link{format}} }
46
 
47
\examples{
11402 ripley 48
x <- c("a", "b", "aaaaaaaaaaa")
49
toString(x)
61150 ripley 50
toString(x, width = 8)
11246 rgentlem 51
}
11402 ripley 52
\keyword{utilities}