| AsIs {base} | R Documentation |
Inhibit Interpretation/Conversion of Objects
Description
Change the class of an object to indicate that it should be treated ‘as is’.
Usage
I(x)
Arguments
x |
an object |
Details
Function I has two main uses.
In function
data.frame. Protecting an object by enclosing it inI()in a call todata.frameinhibits the conversion of character vectors to factors (only relevant ifstringsAsFactors = TRUE) and the dropping of names, and ensures that matrices are inserted as single columns.Ican also be used to protect objects which are to be added to a data frame, or converted to a data frame viaas.data.frame.It achieves this by prepending the class
"AsIs"to the object's classes. Class"AsIs"has a few of its own methods, including for[,as.data.frame,printandformat.In function
formula. There it is used to inhibit the interpretation of operators such as"+","-","*"and"^"as formula operators, so they are used as arithmetical operators. This is interpreted as a symbol byterms.formula.
Value
A copy of the object with class "AsIs" prepended to the class(es).
References
Chambers JM (1992). “Linear Models.” In Chambers JM, Hastie TJ (eds.), Statistical Models in S, chapter 4. Wadsworth & Brooks/Cole.