# Create noisy data around a circle
data = data.frame(x = sapply(1:100, function(x) cos(x)), y = sapply(1:100, function(x) sin(x)))
# Apply lens function to data
projx = data$x
names(projx) = row.names(data)
# Build a width-balanced cover with 10 intervals and 25 percent overlap
num_bins = 10
percent_overlap = 25
xcover = create_width_balanced_cover(min(projx), max(projx), num_bins, percent_overlap)
# Write a function which can check if a data point lives in an interval of our lens function
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