as.vmode is a generic that converts some R ram object to the desired vmode.

as.vmode(x, ...)
as.boolean(x, ...)
as.quad(x, ...)
as.nibble(x, ...)
as.byte(x, ...)
as.ubyte(x, ...)
as.short(x, ...)
as.ushort(x, ...)
# Default S3 method
as.vmode(x, vmode, ...)
# S3 method for class 'ff'
as.vmode(x, ...)
# Default S3 method
as.boolean(x, ...)
# Default S3 method
as.quad(x, ...)
# Default S3 method
as.nibble(x, ...)
# Default S3 method
as.byte(x, ...)
# Default S3 method
as.ubyte(x, ...)
# Default S3 method
as.short(x, ...)
# Default S3 method
as.ushort(x, ...)

Arguments

x

any object

vmode

virtual mode

...

The ... don't have a function yet, they are only defined to keep the generic flexible.

Details

Function as.vmode actually coerces to one of the usual storage.modes (see .rammode) but flags them with an additional attribute 'vmode' if necessary. The coercion generics can also be called directly:

as.boolean1 bit logical without NA
as.logical2 bit logical with NA
as.quad2 bit unsigned integer without NA
as.nibble4 bit unsigned integer without NA
as.byte8 bit signed integer with NA
as.ubyte8 bit unsigned integer without NA
as.short16 bit signed integer with NA
as.ushort16 bit unsigned integer without NA
as.integer32 bit signed integer with NA
as.single32 bit float
as.double64 bit float
as.complex2x64 bit float
as.raw8 bit unsigned char
as.charactercharacter

Value

a vector of the desired vmode containing the input data

Author

Jens Oehlschlägel

See also

Examples

  as.vmode(1:3,"double")
#> [1] 1 2 3
  as.vmode(1:3,"byte")
#> [1] 1 2 3
#> attr(,"vmode")
#> [1] "byte"
  as.double(1:3)
#> [1] 1 2 3
  as.byte(1:3)
#> [1] 1 2 3
#> attr(,"vmode")
#> [1] "byte"