Learn R Programming

SearchTrees (version 0.1.6)

createIndex: Create a Search Tree Index

Description

Create a search tree from the supplied data for use in during futurelookups.

Usage

createIndex(data, type = "quad", columns = c(1, 2), ...)

Arguments

data
Data to create the tree from. Must be a matrix or data.frame like object.
type
Type of tree structure to create. Currently only "quad" is supported
columns
Which columns in data to use to create the tree. Defaults to columns 1 and 2.
...
Any additional/type specific parameters to be passed to the tree creation function.

Value

  • The class of the returned object depends on the tree type created, though all will inherit from the SearchTree S4 class and have the following slots:
  • refAn external pointer to the C level data structure.
  • numNodesTotal number of nodes comprising the tree.
  • dataNodesNumber of terminal/leaf nodes which store at least one data point.
  • maxBucketMaximum number of data points stored in a single terminal/leaf node.
  • pointsNumber of points used to create the tree.

References

Finkel, R. A. and Bentley, J. L. "Quad Trees, a Data Structure for Retrieval on Composite Keys." Acta Informatica 4, 1-9, 1974.

See Also

findKNN, getPointsInRect

Examples

Run this code
x = rnorm(100)
 y = rnorm(100)
 dat = cbind(x,y)
 #maxDepth is a parameter settable for quad trees
 tree = createIndex(dat, maxDepth = 10, type="quad")

Run the code above in your browser using DataLab