Integer Objects

DESCRIPTION:
Creates or tests for objects with storage mode "integer".

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

REQUIRED ARGUMENTS:
x:
any S-PLUS object.

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

VALUE:
integer returns a simple object of storage mode "integer", and the length specified.

is.integer returns TRUE if x is an object of storage mode "integer", and FALSE otherwise.

as.integer returns x if x is a simple object of storage mode "integer". Otherwise, it returns an integer object of the same length as x and with data resulting from coercing the elements of x to storage mode "integer". The numbers are truncated (moved to the closest integer the original number that is towards zero). Attributes are deleted.


DETAILS:
Both as.integer and is.integer are generic functions. There is a "factor" method for is.integer.

Note the difference between coercing to a simple object of storage mode "integer" and setting the storage mode attribute: storage.mode(myobject) <- "integer" This changes the storage mode of myobject but leaves all other attributes unchanged (so a matrix stays a matrix). The value of as.integer(myobject) has no attributes.


BACKGROUND:
In most S-PLUS expressions it is not necessary to explicitly ensure that data are of a particular storage mode. For example, a numeric subscript vector need not be integer; it will be coerced to integer as needed. When testing for data suitable for arithmetic, for example, it is better to use is.numeric(x), which will return TRUE for any numeric object.

SEE ALSO:
ceiling , .Fortran , mode , numeric .

EXAMPLES:
z <- integer(length(zz)) # integer object same length as zz
amp;.Fortran("mysub",as.integer(xm))