mvl_neighbors_lapply: Apply function to indices of nearby rows

View source: R/RMVL.R

mvl_neighbors_lapplyR Documentation

Apply function to indices of nearby rows

Description

Please use generic function mvl_index_lapply() instead.

Usage

mvl_neighbors_lapply(spatial_index, data_list, fn)

Arguments

spatial_index

MVL_OBJECT computed by mvl_write_spatial_index1

data_list

a list of vectors of equal length. They can be MVL_OBJECTs or R vectors.

fn

a function of two arguments - and index into data_list and a corresponding list of indices

Details

This function is passed the index computed by mvl_write_spatial_index1 and a list of vectors, which rows are interpreted as points. For each row, we call the function fn(i, idx), where i gives the index of query row, and idx gives the indices of nearby rows.

Value

a list of results of function fn

See Also

mvl_group

Examples

## Not run: 
Mtmp<-mvl_open("tmp_a.mvl", append=TRUE, create=TRUE)
mvl_write_object(Mtmp, data.frame(x=runif(100), y=1:100), "df1")
Mtmp<-mvl_remap(Mtmp)
mvl_write_spatial_index1(Mtmp, list(Mtmp$df1[,"x",ref=TRUE], Mtmp$df1[,"y", ref=TRUE]),
                                                               c(2, 3), "df1_sp_groups")
Mtmp<-mvl_remap(Mtmp)
mvl_neighbors_lapply(Mtmp["df1_sp_groups", ref=TRUE], list(c(0.5, 0.6), c(2, 3)),
                                           function(i, idx) { return(list(i, idx))})

## End(Not run)

RMVL documentation built on Nov. 2, 2023, 6:09 p.m.