The R Project SVN R

Rev

Rev 86925 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

% File src/library/base/man/AsIs.Rd
% Part of the R package, https://www.R-project.org
% Copyright 1995-2014 R Core Team
% Distributed under GPL 2 or later

\name{AsIs}
\alias{I}
\alias{AsIs}
\alias{print.AsIs}
\alias{[.AsIs}
\title{Inhibit Interpretation/Conversion of Objects}
\description{
  Change the class of an object to indicate that it should be treated
  \sQuote{as is}.
}
\usage{
I(x)
}
\arguments{
  \item{x}{an object}
}
\details{
  Function \code{I} has two main uses.
  \itemize{
    \item In function \code{\link{data.frame}}.  Protecting an object by
    enclosing it in \code{I()} in a call to \code{data.frame} inhibits the
    conversion of character vectors to factors (only relevant if
    \code{stringsAsFactors = TRUE}) and the dropping of
    names, and ensures that matrices are inserted as single columns.
    \code{I} can also be used to protect objects which are to be
    added to a data frame, or converted to a data frame \emph{via}
    \code{\link{as.data.frame}}.

    It achieves this by prepending the class \code{"AsIs"} to the object's
    classes.  Class \code{"AsIs"} has a few of its own methods, including
    for \code{[}, \code{as.data.frame}, \code{print} and \code{format}.

    \item In function \code{\link{formula}}.  There it is used to
    inhibit the interpretation of  operators such as \code{"+"},
    \code{"-"}, \code{"*"} and \code{"^"} as formula operators, so they
    are used as arithmetical operators.  This is interpreted as a symbol
    by \code{terms.formula}.
  }
}
\value{
  A copy of the object with class \code{"AsIs"} prepended to the class(es).
}
\references{
  \bibshow{R:Chambers:1992:c4}
}
\seealso{
  \code{\link{data.frame}}, \code{\link{formula}}
}
\keyword{models}