Character Objects

DESCRIPTION:
Creates or tests for objects of mode "character".

USAGE:
character(length=0)
is.character(x)
as.character(x)

OPTIONAL ARGUMENTS:
length:
integer giving the length of the returned object.

x:
any S-PLUS object.

VALUE:
character returns a character vector of the length specified, containing null strings ("").

is.character returns TRUE if x has mode "character", and FALSE otherwise. 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", and otherwise a character vector of the same length as x and with data resulting from coercing the elements of x to mode "character".


DETAILS:
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.


SEE ALSO:
paste , format , substring , deparse , nchar , mode .

EXAMPLES:
character(length(zz)) # a character object the same length as zz
as.character(1:10) # character representations of 1,2,...,10