lvec: Create memory mapped vector

Description Usage Arguments Details Value Examples

View source: R/lvec.R

Description

The data in these vectors are stored on disk (partially buffered for speed) allowing one to work with more data than fits into available memory.

Usage

1
2
lvec(size, type = c("numeric", "integer", "logical", "character"),
  strlen = NULL)

Arguments

size

the size of the vector

type

the type of the vector. Should be one of the following value: "numeric", "integer", "logical" or "character". The types will create vectors corresponding to the corresponding R types.

strlen

in case of a vector of type "character" the maximum length of the strings should also be specified using strlen.

Details

The minimum value of strlen is two. When a value smaller than that is given it is automatically set to two. This is because a minimum of two bytes is necessary to also store missing values correctly.

Value

Returns an object of type lvec. Elements of this vector are stored on file (partially buffered in memory for speed) allowing one to work with more data than fits into memory.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# create an integer vector of length 100
x <- lvec(100, type = "integer")
# Get the first 10 values; values are initialised to 0 by default
lget(x, 1:10)
# Set the first 10 values to 11:20
lset(x, 1:10, 11:20)

# set maximum length of the string to 1, strings longer than that get
# truncated. However, minimum value of strlen is 2. 
x <- lvec(10, type = "character", strlen = 1)
lset(x, 1:3, c("a", "foo", NA))
lget(x, 1:3)

lvec documentation built on May 2, 2019, 8:16 a.m.