character. There is a big data analog; see
.
character(length=0) is.character(x) as.character(x)
character returns a character vector of the
length specified, containing null strings (
"").
is.character returns
TRUE if
x has mode
"character". Otherwise, it returns
FALSE.
Its behavior is unaffected by any attributes of
x; for example,
x
could be a character array (in contrast to the behavior of
is.vector).
as.character returns
x if
x is a simple
object of mode
"character". Otherwise, it returns a character vector
of the same length as
x and with data resulting from coercing the
elements of
x to mode
"character".
bdCharacter to a
character, you must call
bd.coerce.
Both the
is.character and
as.character functions are generic;
currently there are no methods written for them.
Simple objects have no attributes.
Data elements of objects of
mode
"character" are character strings.
In most S-PLUS expressions it is not
necessary to explicitly ensure that data are of a particular mode.
For example,
the function
paste does not need character arguments; it will coerce data to
character as needed.
Note the difference between coercing to a simple object of mode
"character"
and setting the mode attribute:
mode(myobject) <- "character"
This changes the mode of
myobject but leaves all other attributes unchanged
(so, for example, a matrix stays a matrix).
On the other hand, the value of
as.character(myobject)
has no attributes.
When using ascii codes in a character string, "\n" and "\t" denote ascii
newline and tab characters, respectively, "\\" denotes a backslash, and
"\"" represents a quote within a string. Some other C escape sequences are
allowed but are not supported. Arbitrary ascii codes may be included by
"\nnn" where
nnn is a 3-digit number in octal notation (e.g. "\012" is
the same as "\n"). For a list of ascii characters, see help(ascii).
character(length(zz)) # a character object the same length as zz as.character(1:10) # character representations of 1,2,...,10