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 |
That's all it does. zips them.
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.
Steven E. Pav [email protected]
News for package 'zipper'
start work
Given two sorted arrays, and
, find indices
that ‘zips’
the two together.
zip_le(sortx, looky) zip_lt(sortx, looky)
zip_le(sortx, looky) zip_lt(sortx, looky)
sortx |
a sorted array of ‘reference’ values. |
looky |
a sorted array of values whose place among |
For example, for zip_le
, we find the array of the
same length as
such that there are exactly
elements of
less than or equal to
.
a vector, filled out as follows:
Returns the vector such that there are exactly
elements of
less than or equal to
.
Returns the vector such that there are exactly
elements of
less than
.
Returns zero when there are none, as expected.
it would be better if this code supported mixed types of sortx and looky.
Steven E. Pav [email protected]
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]) }
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]) }