as.integer64.character: Coerce to integer64

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/integer64.R

Description

Methods to coerce from other atomic types to integer64.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
 NA_integer64_
 as.integer64(x, ...)
 ## S3 method for class 'integer64'
as.integer64(x, ...)
 ## S3 method for class 'NULL'
as.integer64(x, ...)
 ## S3 method for class 'character'
as.integer64(x, ...)
 ## S3 method for class 'bitstring'
as.integer64(x, ...)
 ## S3 method for class 'double'
as.integer64(x, keep.names = FALSE, ...)
 ## S3 method for class 'integer'
as.integer64(x, ...)
 ## S3 method for class 'logical'
as.integer64(x, ...)
 ## S3 method for class 'factor'
as.integer64(x, ...)

Arguments

x

an atomic vector

keep.names

FALSE, set to TRUE to keep a names vector

...

further arguments to the NextMethod

Details

as.integer64.character is realized using C function strtoll which does not support scientific notation. Instead of '1e6' use '1000000'. as.integer64.bitstring evaluates characters '0' anbd ' ' as zero-bit, all other one byte characters as one-bit, multi-byte characters are not allowed, strings shorter than 64 characters are treated as if they were left-padded with '0', strings longer than 64 bytes are mapped to NA_INTEGER64 and a warning is emitted.

Value

The other methods return atomic vectors of the expected types

Author(s)

Jens Oehlschlägel <Jens.Oehlschlaegel@truecluster.com>

See Also

as.character.integer64 integer64

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
as.integer64(as.character(lim.integer64()))
as.integer64(
  structure(c("1111111111111111111111111111111111111111111111111111111111111110", 
              "1111111111111111111111111111111111111111111111111111111111111111", 
              "1000000000000000000000000000000000000000000000000000000000000000",
              "0000000000000000000000000000000000000000000000000000000000000000", 
              "0000000000000000000000000000000000000000000000000000000000000001", 
              "0000000000000000000000000000000000000000000000000000000000000010" 
  ), class = "bitstring")
)
as.integer64(
 structure(c("............................................................... ", 
             "................................................................", 
             ".                                                               ",
             "", 
             ".", 
             "10"
  ), class = "bitstring")
)

Example output

Loading required package: bit

Attaching package:bitThe following object is masked frompackage:base:

    xor

Attaching package bit64
package:bit64 (c) 2011-2017 Jens Oehlschlaegel
creators: integer64 runif64 seq :
coercion: as.integer64 as.vector as.logical as.integer as.double as.character as.bitstring
logical operator: ! & | xor != == < <= >= >
arithmetic operator: + - * / %/% %% ^
math: sign abs sqrt log log2 log10
math: floor ceiling trunc round
querying: is.integer64 is.vector [is.atomic} [length] format print str
values: is.na is.nan is.finite is.infinite
aggregation: any all min max range sum prod
cumulation: diff cummin cummax cumsum cumprod
access: length<- [ [<- [[ [[<-
combine: c rep cbind rbind as.data.frame
WARNING don't use as subscripts
WARNING semantics differ from integer
for more help type ?bit64

Attaching package:bit64The following objects are masked frompackage:base:

    :, %in%, is.double, match, order, rank

integer64
[1] -9223372036854775807 9223372036854775807 
integer64
[1] -2   -1   <NA> 0    1    2   
integer64
[1] -2   -1   <NA> 0    1    2   

bit64 documentation built on Aug. 30, 2020, 9:07 a.m.