Index positions to a Hilbert Curve

index(x, ..., n = 10L)

# S3 method for data.frame
index(x, ..., n, coords = c(1, 2), attach = TRUE)

# S3 method for matrix
index(x, ..., n, coords = c(1, 2), attach = TRUE)

# S3 method for double
index(x, y, ..., n)

# S3 method for numeric
index(x, y, ..., n)

# S3 method for integer
index(x, y, ..., n)

index64(x, ..., n = 10L)

# S3 method for data.frame
index64(x, ..., n, coords = c(1, 2), attach = TRUE)

# S3 method for matrix
index64(x, ..., n, coords = c(1, 2), attach = TRUE)

# S3 method for double
index64(x, y, ..., n)

# S3 method for integer
index64(x, y, ..., n)

# S3 method for numeric
index64(x, y, ..., n)

# S3 method for integer64
index64(x, y, ..., n)

# S3 method for character
index64(x, y, ..., n)

# S3 method for bitstring
index64(x, y, ..., n)

## Arguments

x

One of: Numeric vector, data.frame, or matrix. If a numeric vector, then it corresponds to the rows of a position.

...

Unused.

n

Exponent to the dimensions of the underlying grid. The Hilbert Curve indices are based on a 2^n x 2^n grid. This number must be less than 15 due to the 32-bit implementation of R.

coords

Column names or indices of a data.frame/matrix that contain the position coordinates.

attach

If TRUE, adds the indices as a new column to the given data.frame/matrix. If x is a data.frame, then the column is named h; otherwise, it is an unnamed column at the end of the matrix.

y

Numeric vector. Corresponds to the columns of a position.

## Value

An integer vector of Hilbert indices, or when attach is TRUE, the original object (data.frame or matrix) with a new integercolumn (h for data.frame) containing the Hilbert indices. When n is greater than 15, the vector is of type bit64::integer64.