index {hilbert}R Documentation

Index positions to a Hilbert Curve

Description

Index positions to a Hilbert Curve

Usage

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

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

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

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

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

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

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

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

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

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

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

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

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

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

## S3 method for class '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 integer column (h for data.frame) containing the Hilbert indices. When n is greater than 15, the vector is of type bit64::integer64.


[Package hilbert version 0.2.1 Index]