| Title: | An Efficient C/C++ Toolset for R |
|---|---|
| Description: | Accelerated computation for some basic R functions. Compatibility updates by Renova. |
| Authors: | Bastian Pfeifer [aut, cre] |
| Maintainer: | Bastian Pfeifer <[email protected]> |
| License: | GPL-2 |
| Version: | 1.2.9001 |
| Built: | 2026-11-13 18:01:15 UTC |
| Source: | https://github.com/renova-r/BASIX |
This function applies a specific calculation, defined by the user, to all pairs of entries of a vector.
BASIX.combnapply(vec, mode='*')BASIX.combnapply(vec, mode='*')
vec |
vector |
mode |
|
BASIX.combnapply returns values for each pair-combination.
Bastian Pfeifer
vec <- c(1,3,5,7,9,10) BASIX.combnapply(vec)vec <- c(1,3,5,7,9,10) BASIX.combnapply(vec)
This function checks if two vectors are equal, by comparing each cell and quits when the first mismatch occurs.
BASIX.equal(a,b)BASIX.equal(a,b)
a |
first vector |
b |
second vector |
Native R functions compare every entry of the entired vectors,
The R solution would be:
all(a==b)
The function can be applied to numeric as well as character vectors
Bastian Pfeifer
a <- 1:10 b <- a b[2] <- 9 BASIX.equal(a,b)a <- 1:10 b <- a b[2] <- 9 BASIX.equal(a,b)
This function returns the positions of elements which are in a defined region.
BASIX.find.interval(vec,from,to,start=1)BASIX.find.interval(vec,from,to,start=1)
vec |
base vector |
from |
left side |
to |
right side |
start |
the start position |
The function returns the position of the elements in vector vec,
which are in a specific interval, defined by from and to,
starting from position start.
The native R solution would be:
X <- (vec >= from) & (vec <= to) ids <- which(X)
or the function findInterval(), which
is just a little bit slower than
BASIX.interval
Bastian Pfeifer
vec <- c(1,3,5,7,9,10) from <- 5 to <- 8 BASIX.find.interval(vec,from,to,1)vec <- c(1,3,5,7,9,10) from <- 5 to <- 8 BASIX.find.interval(vec,from,to,1)
The function returns a vector of the positions of (first) matches of its first argument in its second.
BASIX.match(elements,vec)BASIX.match(elements,vec)
elements |
values to be matched |
vec |
the values to be matched against |
BASIX.match stops at the first match and continues with the next
element of elements starting from the match position in vec.
The native R solution would be:
match(elements,vec)
Bastian Pfeifer
elements <- c(1,2,10) vec <- c(2,3,4,10,11) BASIX.match(elements,vec)elements <- c(1,2,10) vec <- c(2,3,4,10,11) BASIX.match(elements,vec)
BASIX.table computes the counts of unique rows of a matrix.
BASIX.table(matrix)BASIX.table(matrix)
matrix |
a matrix |
This function can be applied to numeric as well as character matrices.
Bastian Pfeifer
mat <- matrix(0,3,3) mat[1,1] <- 1 BASIX.table(mat)mat <- matrix(0,3,3) mat[1,1] <- 1 BASIX.table(mat)
BASIX.unique returns a matrix with duplicate rows removed.
The unique rows ids will be saved as rownames.
BASIX.unique(matrix)BASIX.unique(matrix)
matrix |
a matrix |
BASIX.unique
is a version of unique specialized on matrices.
The native R solution would be: unique(matrix)
This function can be applied to numeric as well as character vectors.
Bastian Pfeifer
mat <- matrix(0,3,3) mat[1,1] <- 1 BASIX.unique(mat)mat <- matrix(0,3,3) mat[1,1] <- 1 BASIX.unique(mat)