single(length=0) is.single(x) as.single(x)
is.single returns TRUE if x is an object of storage mode "single", and FALSE otherwise.
as.single returns x if x is a simple object of storage mode "single", and otherwise a simple object of the same length as x and with data resulting from coercing the elements of x to storage mode "single". Attributes are deleted.
In most S-PLUS expressions it is not necessary to explicitly ensure that data are of a particular storage mode. 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. Normally, S-PLUS does numeric computations with double precision. About the only need for storage mode "single" comes when using the interface to a Fortran subroutine with arguments that are declared REAL. (see .Fortran.)
Note the difference between coercing to a simple object of storage mode single and setting the storage mode attribute: storage.mode(myobject) <- "single" This changes the storage mode of myobject but leaves all other attributes unchanged (e.g., a matrix stays a matrix). The value of as.single(myobject) has no attributes.
z <- single(length(zz)) # a single object same length as zz amp;.Fortran("mysub",as.single(x))