How to create an integer64 vector in R?

R ProgrammingServer Side ProgrammingProgramming

The integer64 vector contains vector values that represents signed integers with values that range from negative 9,223,372,036,854,775,808 to positive 9,223,372,036,854,775,807. To create an integer64 vector, we can use as.integer64 function of bit64 package. The difference between integer64 vector and others is that a large number of values can be stored in the vector.

Example

library(bit64)
x1<-as.integer64(sample(0:9,200,replace=TRUE))
x1

integer64

Output

[1]  4 3 1 3 8 8 4 5 6 2 8 7 5 0 2 4 8 4 6 7 3 9 5 2 1 1 5 7 6 0 3 9 9 8 1 0 0
[38] 6 8 8 5 8 7 1 9 8 9 2 5 6 7 9 5 9 8 6 3 5 6 1 7 7 6 8 6 9 0 9 8 2 4 9 8 5
[75] 5 8 7 7 4 2 7 9 5 7 9 6 0 7 4 1 0 0 4 7 0 3 7 3 4 0 8 0 4 3 5 2 7 2 5 6 8
[112] 9 9 1 5 5 7 7 2 1 4 5 3 1 3 4 3 3 1 7 2 2 8 2 1 0 0 9 6 8 1 8 6 0 6 1 0 0
[149] 6 2 3 8 3 4 9 2 7 5 3 1 8 4 2 6 9 2 2 2 1 9 2 6 7 6 3 3 1 8 0 1 3 1 4 6 0
[186] 3 5 8 2 0 1 2 8 0 8 8 9 5 1 0

Example

x2<-as.integer64(sample(1:100,200,replace=TRUE))
> x2

integer64

Output

[1]  41 98 21 92 52 50 49 93 31 46 33 71 21 59 87 7 16 10
[19] 43 51 76 29 33 80 56 85 42 89 45 96 71 56 42 70 76 31
[37] 55 76 100 75 87 95 27 53 71 51 56 90 9 3 41 9 8 32
[55] 94 39 74 13 24 93 7 37 60 41 38 23 25 31 54 96 31 36
[73] 72 30 21 98 16 25 7 28 98 80 56 20 66 55 76 14 91 87
[91] 15 71 46 6 21 79 54 29 58 81 18 60 31 5 34 51 9 93
[109] 58 95 72 26 99 25 53 27 10 77 24 35 87 11 11 5 16 55
[127] 82 70 30 44 49 33 61 69 46 10 42 44 64 73 93 87 94 72
[145] 77 78 6 37 82 71 63 75 65 97 94 90 64 42 91 30 21 64
[163] 24 74 21 11 95 33 35 85 14 38 87 46 73 82 21 38 77 84
[181] 8 95 48 61 75 32 70 51 29 49 17 94 36 41 30 46 69 36
[199] 31 2

Example

x3<-as.integer64(sample(100:999,200))
x3

integer64

Output

[1]  119 113 220 224 624 541 374 695 190 214 672 505 719 559 147 903 714 783
[19] 575 121 696 765 232 462 908 171 213 554 431 928 533 507 979 536 767 492
[37] 959 526 746 472 362 455 843 570 405 546 229 436 620 223 521 184 256 510
[55] 291 128 778 470 387 381 804 794 825 666 933 781 686 216 735 994 630 268
[73] 557 690 634 324 978 141 918 304 654 821 755 740 286 972 346 965 370 700
[91] 887 194 925 549 163 579 328 636 368 788 841 500 543 249 179 315 590 282
[109] 528 150 204 883 443 705 702 886 839 353 739 866 682 999 233 447 914 193
[127] 506 986 996 716 104 924 896 803 231 784 677 186 458 242 947 939 613 832
[145] 423 412 445 643 332 372 417 660 671 871 797 234 754 519 504 164 426 952
[163] 568 605 334 799 453 323 474 427 958 995 789 721 414 879 840 850 255 973
[181] 168 552 961 195 429 964 882 764 852 354 340 277 627 188 169 430 493 854
[199] 621 134

Example

x4<-as.integer64(sample(rpois(5,20),200,replace=TRUE))
x4

integer64

Output

[1]   24 17 17 18 18 24 18 24 17 24 24 24 18 24 17 17 17 24 24 18 24 24 17 24 24
[26]  24 17 18 17 24 24 17 24 17 18 17 18 24 24 18 24 17 17 24 24 17 24 18 18 17
[51]  24 24 17 24 17 24 24 17 17 17 17 17 24 17 24 24 17 17 24 17 24 24 17 17 17
[76]  24 17 24 24 17 24 17 24 17 18 17 17 17 24 24 17 17 18 18 17 18 24 17 17 17
[101] 17 24 24 17 24 24 17 24 17 24 17 24 24 24 17 17 17 18 17 17 24 24 17 17 17
[126] 24 24 24 17 24 17 24 17 18 24 17 18 17 24 18 18 24 17 17 17 18 17 17 24 24
[151] 17 24 17 17 17 18 24 24 17 24 24 18 17 17 17 18 24 17 17 18 18 17 24 18 18
[176] 24 17 24 24 24 17 18 24 17 17 18 24 24 18 24 17 24 18 24 17 17 17 17 17 24

Example

x5<-as.integer64(sample(rnorm(10),200,replace=TRUE))
x5

integer64

Output

[1]   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[38]  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0
[75]  0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
[112] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[149] 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0
[186] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Example

x6<-as.integer64(sample(rexp(10),200,replace=TRUE))
x6

integer64

Output

[1] 1 0 1 1 0 0 0 0 1 1 0 1 0 0 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
[38] 1 0 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 1 0 0 0 1 0 1 1 0 0 0 1 0
[75] 0 0 0 0 0 0 1 0 0 1 1 0 1 0 1 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0
[112] 1 0 0 0 1 0 1 0 1 1 1 1 1 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 1 0 1
[149] 0 1 1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0
[186] 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0

Example

x7<-as.integer64(sample(runif(10,2,5),200,replace=TRUE))
x7

integer64

Output

[1] 3 2 3 4 3 3 3 3 2 2 3 2 3 4 3 3 3 3 4 2 2 3 2 2 3 2 4 2 4 4 4 3 2 4 4 2 2
[38] 3 4 2 3 4 4 4 4 4 4 4 2 2 3 3 3 3 4 4 3 2 2 2 4 3 3 3 3 3 2 3 2 2 3 3 3 3
[75] 2 4 4 4 4 3 3 3 4 2 2 3 3 4 3 2 3 3 4 4 4 3 3 2 4 2 4 4 2 4 4 3 2 3 4 4 4
[112] 4 3 3 3 3 3 4 4 3 2 3 2 2 2 3 3 4 3 4 3 3 4 2 4 4 4 3 2 3 3 3 4 3 3 3 3 3
[149] 2 3 2 3 3 3 3 3 4 3 2 3 3 4 3 2 4 2 3 3 2 4 4 2 2 4 4 4 3 3 3 4 2 3 3 2 3
[186] 4 2 4 3 3 2 2 2 3 3 3 2 3 3 2

Example

x8<-as.integer64(sample(runif(10,0,5),200,replace=TRUE))
x8

integer64

Output

[1] 3 1 2 0 3 1 2 0 4 3 0 0 1 2 1 2 2 0 2 0 1 4 0 0 0 3 1 0 0 3 4 4 0 1 1 0 1
[38] 4 2 1 0 0 0 4 0 2 0 3 1 0 1 2 2 2 4 2 1 0 1 1 1 1 0 1 1 2 1 3 1 1 0 0 0 4
[75] 0 0 3 1 2 2 2 2 0 0 0 4 1 0 1 3 1 1 0 0 2 4 1 1 0 2 0 1 4 4 0 2 3 1 0 0 1
[112] 3 0 1 2 4 0 3 0 4 0 0 0 0 4 0 1 2 1 4 1 4 2 2 1 4 1 1 2 1 3 1 0 3 1 2 2 4
[149] 3 0 2 4 0 3 4 4 1 1 2 2 3 0 1 0 2 2 1 2 0 0 2 3 1 2 4 0 0 0 4 1 0 2 4 1 1
[186] 3 0 1 0 2 4 0 1 3 4 4 1 1 0 2
raja
Published on 10-Feb-2021 06:24:56
Advertisements