If you are unsure of the type of an object, check it by using the
set of functions that begin with is. There is one for almost every
type of object, and they return ``T'' or ``F''
(true or false) depending on whether the object in question is of that
type.
> is.vector(blah) [1] T > is.character(blah) [1] T > is.numeric(blah) [1] FIn the above example, S-PLUS was asked whether
blah was
a vector (true), a character (true, a character vector), or a
numeric (false).
S-PLUS can change objects from one type to another, but only if there is an obvious way to do so.
> as.numeric("1")
[1] 1
> as.numeric("hello")
[1] NA
Warning messages:
1 missing value generated coercing from character to numeric in: as.numeri\
c("hello")
In the example above, S-PLUS knew how to change the symbol ``1'' into
the number 1, but not how to change the word ``hello'' into a number. Some
uses of the as functions will be shown in subsequent sections.