character {base}R Documentation

Character Vectors


Create or test for objects of type "character".


character(length = 0)
as.character(x, ...)


length desired length.
x object to be coerced or tested.
... further arguments passed to or from other methods.


as.character and is.character are generic: you can write methods to handle specific classes of objects, see InternalMethods.


character creates a character vector of the specified length. The elements of the vector are all equal to "".
as.character attempts to coerce its argument to character type; like as.vector it strips attributes including names.
is.character returns TRUE or FALSE depending on whether its argument is of character type or not.


as.character truncates components of language objects to 500 characters (was about 70 before 1.3.1).


Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

See Also

paste, substr and strsplit for character concatenation and splitting, chartr for character translation and casefolding (e.g., upper to lower case) and sub, grep etc for string matching and substitutions. Note that = "character") gives even more links. deparse, which is normally preferable to as.character for language objects.


form <- y ~ a + b + c
as.character(form)  ## length 3
deparse(form)       ## like the input

[Package base version 2.1.0 Index]