Learn R Programming

mappeR (version 2.0.2)

create_mapper_object: Create a mapper object

Description

Run the mapper algorithm on a data frame.

Usage

create_mapper_object(
  data,
  dists,
  filtered_data,
  cover_element_tests,
  clusterer = NULL
)

Value

A list of two dataframes, one with node data and one with edge data.

Arguments

data

A data frame.

dists

A distance matrix for the data frame.

filtered_data

The result of a function applied to the data frame; there should be one filter value per observation in the original data frame.

cover_element_tests

A list of membership test functions for a set of cover elements. In other words, each element of cover_element_tests is a function that returns TRUE or FALSE when given a filter value.

clusterer

A function which accepts a list of distance matrices as input, and returns the results of clustering done on each distance matrix. Defaults to NULL, meaning no all data in each bin will be lumped into a single cluster.

Examples

Run this code
data = data.frame(x = sapply(1:100, function(x) cos(x)), y = sapply(1:100, function(x) sin(x)))
projx = data$x

num_bins = 10
percent_overlap = 25
xcover = create_width_balanced_cover(min(projx), max(projx), num_bins, percent_overlap)

check_in_interval <- function(endpoints) {
 return(function(x) (endpoints[1] - x <= 0) & (endpoints[2] - x >= 0))
}

# each of the "cover" elements will really be a function that checks if a data point lives in it
xcovercheck = apply(xcover, 1, check_in_interval)

# build the mapper object
xmapper = create_mapper_object(
  data = data,
  dists = dist(data),
  filtered_data = projx,
  cover_element_tests = xcovercheck
)

Run the code above in your browser using DataLab