Package 'zipper'

Title: Zip Sorted Arrays Together
Description: Just zips together sorted arrays.
Authors: Steven E. Pav [aut, cre]
Maintainer: Steven E. Pav <[email protected]>
License: LGPL-3
Version: 0.1.0.1000
Built: 2024-11-06 03:56:21 UTC
Source: https://github.com/shabbychef/zipper

Help Index


Zip Sorted Arrays Together

Description

That's all it does. zips them.

Legal Mumbo Jumbo

zipper is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

Author(s)

Steven E. Pav [email protected]


News for package 'zipper':

Description

News for package 'zipper'

Initial Version 0.1.0 (2017-05-01)

  • start work


Zip sorted arrays against each other

Description

Given two sorted arrays, xx and yy, find indices LL that ‘zips’ the two together.

Usage

zip_le(sortx, looky)

zip_lt(sortx, looky)

Arguments

sortx

a sorted array of ‘reference’ values.

looky

a sorted array of values whose place among sortx is to be found.

Details

For example, for zip_le, we find the array LL of the same length as yy such that there are exactly LiL_i elements of xx less than or equal to yiy_i.

Value

a vector, filled out as follows:

zip_le

Returns the vector LL such that there are exactly LiL_i elements of xx less than or equal to yiy_i.

zip_lt

Returns the vector LL such that there are exactly LiL_i elements of xx less than yiy_i.

Note

Returns zero when there are none, as expected.

it would be better if this code supported mixed types of sortx and looky.

Author(s)

Steven E. Pav [email protected]

Examples

set.seed(1234)
x <- sort(rnorm(1e5))
y <- sort(rnorm(1e2))
idx1 <- zip_le(x,y)
# slow way, should give the same answer
uther <- rep(NA,length(y))
for (iii in 1:length(y)) {
  uther[iii] <- sum(x <= y[iii])
}