pkern_sub: Return a sub-grid of a pkern grid object

View source: R/pkern_index.R

pkern_subR Documentation

Return a sub-grid of a pkern grid object

Description

Removes grid lines as specified in ij and returns the result as a pkern grid list; If ij is empty, the function attempts to find a set of grid lines that forms a complete regular sub-grid of g_obs.

Usage

pkern_sub(g_obs, ij = list(), mirror = FALSE, idx = FALSE)

Details

ij can be a list of integer vectors, named i and j, specifying grid line numbers to remove, in ascending order. ij can also be a nested list, with the grid lines to remove in element remove. Alternatively, users can specify the grid lines to NOT remove in element keep, and the function will remove the others. If both keep and remove are specified, the function ignores keep and uses remove.

Default idx=FALSE causes the function to return the sub-grid as a pkern grid object. If idx=TRUE, the function instead returns a list containing keep and remove as specified above. This can be passed back to pkern_sub when repeatedly cropping multiple grids in the same way.

mirror=TRUE indicates to mirror the supplied selection of grid lines in ij about the central grid line. For example ij_rem=list(i=1) removes both the first (left-most) column and the last (right-most).

When ij is an empty list(), the function sets ij automatically using a greedy algorithm that iteratively checks all (four) outer grid lines and removes the one with the highest proportion of NAs. Ties are broken in clockwise order, starting from the left vertical. The algorithm stops when the remaining sub-grid is complete.


deankoch/pkern documentation built on Oct. 26, 2023, 8:54 p.m.