Fix psort() corrupting the sort order and reading out of bounds for latin1 or byte strings whose first byte is 0xFF; the byte is now mapped to bucket 256 instead of wrapping to bucket 0. Add ascending, descending and random-byte regression tests.
Fix funique(), fduplicated(), uniqLen() and countOccur() crashing or hanging on logical vectors containing codes other than TRUE, FALSE or NA (for example from readBin(..., "logical", size = 4)). Invalid codes are folded into the NA slot instead of being used as hash-table indices.
Fix funique(), fduplicated(), uniqLen() and countOccur() on data frames whose first column is longer than the data-frame row count (a matrix column is a valid R data frame column). The row count now comes from the data frame, and matrix, list and raw columns are rejected with a clear error before any column is copied or indexed.
Fix iif(..., tprom = TRUE) mutating caller-owned no and na vectors and silently relabelling factors with different levels; attributes are only applied to copies, and incompatible factor levels now error. Fix type promotion leaving stale classes and levels, which produced malformed factors and Date-classed character results.
Fix psum() and pprod() retaining a Date or other class when promotion produced a complex result.
Fix psum(), pprod() and pmean() turning an arithmetic NaN into NA when a later argument was NA. psum() and pmean() also normalise negative zero to match base sum() and mean().
Fix fpos(..., all = FALSE) allocating the whole search space instead of one result slot; the first-match path now uses constant memory.
Fix psort()'s non-character fallback for complex vectors by not forcing the unsupported radix method.
Preserve names, dimensions and dimnames in iif(), nif(), fpmin(), fpmax(), prange() and row-subset matrices; copyMostAttrib() intentionally omits these attributes.
Fix count() treating NA as a value for integer, logical and character vectors but not for double and complex vectors; missing values are consistently not counted, and countNA() remains the dedicated counter.
Fix zero-column matrices in funique(), fduplicated() and uniqLen() to match base R (zero rows, zero duplicates and zero unique values).
Replace the write through a read-only data pointer in the list branch of pfirst() with SET_VECTOR_ELT().
Give NULL values in iif() and nif() a clear error instead of “attempt to set an attribute on NULL”.
Check the owner and permissions of existing POSIX shared-memory objects before using them, so a local user cannot read or poison another user's shareData() object by creating the name first.
Replace unchecked malloc/calloc in psort() and countOccur() with R's checked allocation, and remove countOccur()'s unused full-length scratch vector.
Merge the near-identical fpmin() and fpmax() implementations into one worker; the duplicated radix routines and row loops were fixed in place and are covered by the new regression tests.
Make configure use $CC when choosing the Darwin GCC/Clang runtime, add -lrt only on Linux, and always write a fallback src/Makevars so an unusual compiler cannot silently produce a serial build.
Strengthen the tests: only skip shareData() tests for a recognized shared-memory availability error, fail re-share errors after a successful first share, and add 156 regression assertions covering all the cases above.
Add tools/benchmark-audit.R for reproducible baseline/patched timing of the hot functions.
Make string comparison honour declared encodings in count(), pcount(), fpos() and setlevels(): the same text stored as latin1 and UTF-8 is now one value, matching base R. funique(), fduplicated(), uniqLen(), countOccur() and charToFact() gain checkEnc to do the same; it defaults to FALSE so the previous fast internal-string path is unchanged unless mixed encodings are requested explicitly.
Fix nif() evaluating the first condition twice and evaluating later pair outputs even when their condition can never match. The first pair now reuses its already evaluated condition and value, and an unused pair can no longer run side effects or stop().
Fix nif() writing row positions into an int tracker on conditions longer than INT_MAX; positions are now stored in R_xlen_t.
Fix pcount() bypassing its length check for value = integer(0) or a value vector of length greater than 1; these now error instead of silently counting NAs.
Fix nswitch() not checking that each value has the same class and factor levels as x, which could match factor values by their internal codes.
Fix fpos() rejecting ordinary matrices that have dimnames, and rejecting 3-D arrays instead of flattening them into a vector.
Accept a numeric kit.nThread option in psort() and charToFact(), like the other threaded functions. charToFact() now keeps names, and the psort() documentation records that it drops them.
Remove the unfinished index = TRUE path in the registered C helper cpsortR(); it now returns a clear error.
Fix nif() segfaulting when called without condition/value pairs (e.g. nif() or nif(default = 1)): the argument count is now validated before any pair is read, and the call errors with a clear message (#130).
Fix pany(..., na.rm = TRUE) treating NA as TRUE when called with a single argument: the one-argument fast path now maps NA to FALSE, matching base any() and the multi-argument path, so pany(c(NA, FALSE), na.rm = TRUE) is c(FALSE, FALSE) (#131).
Fix psort() on all-unique character input with NA: with decreasing = TRUE, na.last = TRUE left NA at the front, na.last = FALSE (with c.locale = FALSE) moved it to the back, and na.last = NA could keep it. NA is now moved to the requested end before removal, matching base sort() for both c.locale values (#132).
Fix pprod() returning a wrong complex product when an imaginary part is nonzero: the complex branch now computes the real and imaginary parts before assigning either, so pprod(1+2i, 3+4i) is -5+10i (both na.rm branches, #133).
Fix pfirst()/plast() with a single argument returning a one-element list instead of the input vector, so pfirst(1:4) is 1:4 and a one-column data frame returns its column (#134).
Fix setlevels() corrupting factors: a new value colliding with an untouched level produced duplicated levels, and a missing old value errored after earlier levels had already been replaced. The replacement is now built and validated on a copy of the levels and installed once, so errors leave x unchanged (#135). Overlapping old and new entries are now applied simultaneously, so a newly set level is not matched again by a later entry.
Fix fpos() and countOccur() overflow on inputs too large for their int loop indices and search-space sizes. fpos() now refuses a matrix whose size or search space exceeds INT_MAX (its search space, offsets and loop indices are int) and a vector whose length or search space exceeds INT_MAX before allocating the result, including zero-length needles where the search space is one element larger than the haystack, and countOccur() applies its existing long-vector guard to logical vectors too, so these inputs error with "Long vector not supported yet" instead of wrapping, reading out of bounds or corrupting memory (#138).
Fix shareData() silently destroying an existing mapping when map_name ended in _key: the length object of foo is stored as foo_key, so sharing under foo_key overwrote it and getData("foo") failed. Names ending in _key are now rejected in shmName() with a clear error. Objects created under such a name by earlier versions can no longer be read through getData(); re-share them under a new name and remove the old mapping with OS tools (#139).
Fix integer psum() silently wrapping on overflow. Running sums are now checked past the integer range (and against INT_MIN, which is NA in R), so psum(.Machine$integer.max, 1L) returns NA_integer_ with base's "NAs produced by integer overflow" warning, and overflow is sticky (INT_MAX + 1 - 1 stays NA). Elements already NA no longer trigger a spurious overflow warning. The double and complex paths are unchanged (#129).
Fix getData() on POSIX reporting * Cleaning shared memory mapping...ERROR after a successful read when another reader had already unlinked the shared memory object. An already-removed name now counts as cleaned up, so readers that attached before the first unlink return their data (#118).
Fix charToFact(..., addNA = FALSE) dropping the last real level when NA was present with decreasing = TRUE, when no NA was present at all, or erroring on character(0). The NA level is now removed before the lookup table is built, so every real level survives; addNA = TRUE behaviour is unchanged.
Fix shareData() on POSIX letting clearData() on an older pointer unlink a newer object created by re-sharing the same name: a fresh ownership token is now written on every mapping write, so the older pointer only cleans up its own view. After a re-share, call getData() or remove the shared memory object to free it (#55 follow-up).
Fix funique()/fduplicated()/uniqLen() on zero-column data frames: they read the first column before checking for columns, so frames with rows but no columns did an out-of-bounds read. They now count rows from row.names. countOccur() now gives a clear error instead of reading a missing column.
Fix topn() silently ignoring unregistered xtfrm() methods for classed numeric vectors: xtfrm() is now evaluated in the base namespace, whose parent is the global environment, so top-level and attached-package methods are used, a caller's local xtfrm cannot shadow the base generic, and the result still matches order() (#111).
Fix topn() returning invented indices or crashing when a classed vector's xtfrm() method changes the result length: the radix fallback over-read the shorter order() result, and a zero-length result segfaulted. A length-changing xtfrm() result now errors, and a classed xtfrm() result is unclassed before sorting so xtfrm() is applied once, not twice (#114).
Fix vswitch()/nswitch() with checkEnc = TRUE when the first string is already UTF-8 but later elements are latin1 or NA: enc2UTF8() now checks every element and preserves NA_STRING, and value-major nswitch() compares each pair against its own converted value instead of the first one.
Fix funique()/fduplicated()/uniqLen() hashing -0 and differing NaN payloads as distinct doubles. Vector, matrix and data-frame paths now canonicalise doubles the same way REQUAL compares them, matching base R.
Fix shareData and getData on platforms where shm_open requires names to start with a slash, e.g. FreeBSD. Shared memory object names are now normalized on all POSIX platforms as recommended by POSIX. Thanks to @nunotexbsd for raising an issue (#40).
Fix a mapping leak in getData where the wrong region was unmapped during cleanup.
Keep .git out of source tarballs and remove the macOS a.out.dSYM probe file during configuration.
Speed up setlevels() from quadratic to linear by hashing old once and scanning the levels once. The factor's data is no longer duplicated: the levels are changed in place and x is returned (#136).
Speed up vswitch() and nswitch() when there are many value/output pairs. For more than 8 pairs the implementation builds a value-to-last-pair hash map once and scans x in cache-sized blocks instead of comparing x against every value. Matching semantics are unchanged: integer/logical NA still matches NA, doubles/complex canonicalise -0 and never match NA/NaN, strings compare CHARSXP identity, duplicate values keep the last pair, and threaded results stay deterministic. On 2m elements, 20 values are about 2-2.5x faster and 100 values 4.5-5.7x faster; the value-major path is kept for 8 or fewer pairs.
Speed up funique()/fduplicated()/uniqLen() on data frames and matrices. Row hashes now use a 64-bit rolling mix instead of mixing every cell and mixing again, and a bounded sample estimates cardinality so high-cardinality inputs allocate the final table once while low-cardinality inputs keep the small grow-on-demand table. On 10m rows, 2-column integer data frames improve about 2.5x and mixed integer/double frames about 2.3-2.5x; 2m frames improve 1.5-1.8x. The scalar vector path was left unchanged: it is already faster than data.table::uniqueN() and dedicated hash variants stayed under the 20% threshold.
Add tools/benchmark-core.R, a manual benchmark covering 2m/10m elements, 5/20/100 switch values, integer/string/factor/NA inputs, data frames, and 1/2/4 threads. It is not run in CI.
Fix nswitch() with duplicate values and nThread > 1: the outer loop over value/output pairs is now serial and atomic-output pairs are parallelised over the elements of x, so the last matching pair wins deterministically. Also fix the list-input/logical-output path reading output element i instead of j (#63 follow-up).
Fix fduplicated() on logical vectors longer than INT_MAX: the generic path used an int loop index and stored i + 1 in an int table slot, so a multi-gigabyte logical vector could overflow and read out of bounds. It now raises the standard "Long vector not supported yet" error (#61 follow-up).
Apply xtfrm to classed vectors before the topn() long-vector heap path, so custom classes follow order() semantics there too; classed long vectors whose xtfrm is not integer/double now error clearly instead of falling back to the integer-index order() path (#83 follow-up).
Fix nswitch() segfaulting when called without value/output pairs (e.g. nswitch(1:3) or nswitch(1:3, default = 0L)): the argument count is now validated before any pair is read, and the call errors with a clear message (#87).
Evaluate the internal order()/sort() calls in topn, psort, and charToFact in the base environment. A caller-defined order/sort could previously shadow them and make topn return out-of-bounds indices or psort/charToFact error or sort incorrectly (#74).
Fix shared-memory lifetime and error-path safety in shareData(): POSIX mapping names are now owned copies, long-vector lengths, allocation sizes, and existing mapping sizes are checked, finalizer verbosity is per mapping, failed mappings release descriptors, mappings, and temporary state, reader cleanup is unwind-safe, and finalizers verify mapping identity before unlinking owned names (#55).
Fix segfault in vswitch/nswitch on length-0 character input: the character encoding path dereferenced element 0 without checking length. The encoding check is now skipped for empty x and isMixEnc/enc2UTF8 handle empty input safely, with no overhead on the fast path (#66).
Fix .onAttach/.onLoad crash on bad kit.nThread (NULL/NA/length != 1): the option is now sanitized to 1L, the default is restored via is.null(getOption()), and the startup message only prints in interactive sessions (#56).
Keep nswitch's per-output recycle mask on the heap instead of the C stack, matching vswitch, so a very large number of value/output pairs cannot overflow the stack (#74).
Fix shareData/getData/clearData input validation: bad map_name (""/NA/length != 1/non-character) and verbose (NA/non-logical/length != 1) now fail fast in R with a clear message instead of reaching shm_open and its cryptic error; connections are closed via on.exit even when serialize/unserialize fails (#59).
Audit compiled length handling for 64-bit long vectors: IS_BOOL/IS_LOGICAL and the character psort/charToFact paths now use XLENGTH() (long character vectors are refused with the standard "Long vector not supported yet" error before any data is read), funique/uniqLen handle > 2^31 elements for factors and logicals, topn on long inputs returns double indices like base::order, subSetRowMatrix row indexing no longer overflows for matrices with >= 2^31 cells, and byte-size casts that truncated above 4 GiB are fixed (#61).
Fix two segfaults found while auditing length handling (#61): funique/uniqLen on factors containing NA read the count table out of bounds (the NA code is now kept in its own slot and missing elements are returned in the same order as base::unique/length(unique())), and dfToMatrix refused to bound-check a flat int index, so funique/uniqLen on data.frames with more than INT_MAX cells (e.g. 50k columns) wrote out of bounds; such data.frames now raise the standard "Long vector not supported yet" error. Factor codes outside 1..nlevels (e.g. after attr(x, "levels") surgery) no longer index the count table out of bounds either and are returned as NA like base; distinct invalid codes collapse into one missing value.
Guard the mixed-type data.frame paths in funique/fduplicated (dupDataFrameR), uniqLen (dupLenDataFrameR), and countOccur (countOccurDataFrameR): with more than INT_MAX rows the row count was truncated to int inside allocMatrix(), so 2^31-2^32 rows errored with R's confusing "negative extents to matrix" message (and above 2^32 rows the mixed funique/uniqLen logical-column case could write out of bounds, which the per-column 2^30 guard only prevents for other types). These paths now stop up front with the standard "Long vector not supported yet" error, before any allocation, when the rows exceed INT_MAX or the matrix would exceed INT_MAX cells — the same bound the all-same-type branch has applied to dfToMatrix() since the length audit (#61), so the same data.frame now fails the same way regardless of whether its columns share one type (#82).
Mix hashed keys with a 32-bit avalanche before indexing the growable duplicate tables. The previous top-bits-only multiplicative hash mapped sequential integer IDs to only ~16% of the slots in a power-of-two table, so funique()/fduplicated()/uniqLen() fell back to long linear-probe scans on common ID-like data. The tables still start at 256 slots and grow on demand; adding tools/benchmark-unique.R keeps this case visible.
Document ?kit with a package page that explains OpenMP threads, platform support, encoding behavior, and the main functions. Add "OpenMP and threads" and "Platforms" sections to the README, and add library(kit) to the first README example (#90).
Reduce peak memory in funique, fduplicated, uniqLen, psort, and charToFact by starting duplicate hash tables at 256 slots and growing them on demand (4x, capped at the previous full-size table) instead of allocating the full table up front. Rehashing re-reads the source values, so results are unchanged; inputs with few unique values use much less memory, while peak memory can be higher at growth boundaries for high-cardinality inputs (#74).
Speed up vswitch for string and list outputs by scanning x once instead of once per value and fusing default/na writes into the match pass; single-value lookups also avoid a separate initialization pass. Atomic outputs keep the value-major vectorized pass, with the first value fused into initialization. Last-match-wins behavior for duplicate values is preserved, mixed output item types now fail with a clear error, and list-output scratch arrays are heap allocated so large outputs no longer exhaust the C stack (#74).
Bound the topn linear candidate scan: input ordered opposite to decreasing made every element replace the current worst and rescan all n candidates, so n = 1500 on 2e7 elements took ~14.5 s. The scan now falls back to the existing radix order() path once its rescan work exceeds a few passes over the input, reducing that case to ~0.11 s while leaving random and small-n inputs on the fast path. The fallback allocates a full-length order index, so peak memory is higher on adversarial inputs. Classed numeric vectors have xtfrm applied once and then use the same fast selector, so a custom class ordering matches order() without forcing a full radix sort for identity classes such as Date, POSIXct, and factors (#74).
Serialize shareData payloads directly to a raw vector instead of through a raw connection, removing one full-payload copy on write and connection overhead on read; the shared-memory format is unchanged (#74).
Reduce topn memory use on long vectors (more than INT_MAX elements): the long path allocated a full-length radix order() index (~8 x length bytes, ~17 GB for a 2^31-element input, only to return n indices) and is replaced by a bounded heap of the n best (value, index) entries, so memory is now proportional to n; unmaterialized ALTREP inputs are read element-wise without being materialized. The result is unchanged — double indices like order(vec, method="radix", na.last=TRUE)[1:n], ties and missing values keeping input order regardless of hasna — and decreasing=TRUE now works on such inputs, where the order() path errored with base R's "long vectors not supported" (#83).
Document the shareData/getData/clearData contract in ?shareData: deep-copy cost (object serialized once, then copied into and out of shared memory, not a pointer), single-read getData, lifetime and cleanup semantics, platform differences, and a two-session \dontrun example; cross-links the zero-copy request (#43) (#60).
Clean up DESCRIPTION metadata: bump Depends to R (>= 3.5.0) to match the DATAPTR_RO fallback in src/kit.h (...length(), R_RegisterCCallable/STRING_PTR_RO need newer than 3.1), use ByteCompile: yes per WRE, drop Repository: CRAN from the dev tree, and add Config/Needs/website: pkgdown (Suggests already covers data.table/tibble/tinytest used in tests and vignette) (#58).
The test suite was migrated to tinytest: the legacy custom check() only printed failures without stopping, so regressions went unnoticed. Tests now fail loudly (1271 expectations) with zero additional dependencies.
Replace the remaining Rboolean scalars in the C sources with bool (callToOrder, dupMatrixR, topnR, and the hasFactor flags in psum), keeping asLogical() as the R-value boundary. Rboolean is only intended for the TRUE/FALSE enum and misbehaves for logical vector elements under stdbool.h and C23, as reported by @aitap in #42. The LGLSXP/INTSXP branches in subSetColMatrix are merged since LOGICAL() and INTEGER() are both int* (#62).
Reduce a redundant initialization pass in multi-argument psum(..., na.rm = TRUE) for integer, double, and complex inputs while preserving missing-value semantics (#74).
New test coverage for fpmin/fpmax/prange (NA/NaN + na.rm, logical < integer < double promotion, prange double-only rule, single list/data.frame path), kit.nThread = 1 vs 2 determinism (iif/vswitch/nswitch/charToFact/psort), and mixed-encoding checkEnc, funique data.table/tibble attributes, Date/factor preservation and empty inputs (#63, tests-only, no C changes). Coverage now requires > 90% via Codecov.
Add a root .gitignore for build artifacts (src/*.o, src/kit.so, the src/Makevars that configure generates, *.tar.gz, *.Rcheck/, cobertura.xml, docs/, and R session junk), so an in-tree R CMD INSTALL no longer leaves 13 untracked files that a stray git add -A would commit. The src/Makevars rule is narrow so the tracked src/Makevars.in and src/Makevars.win stay visible, and the tracked cleanup script is deliberately not ignored: it is what keeps the generated Makevars out of the distribution tarball (#78).
File descriptors from shm_open are now closed after the mappings are established.
The test suite now skips shareData checks gracefully when POSIX shared memory is unavailable instead of aborting the whole run.
fpmin, fpmax, and prange are added as parallel equivalents of base R pmin, pmax, and range operations. These functions compute element-wise minimum, maximum, and range (max - min) across multiple vectors. They support integer, logical, and double types, with automatic type promotion. Implemented by @SebKrantz.Update copyright date in c files
Fix note on CRAN regarding Rf_isFrame
iif tests for new version of R.nswitch. Thanks to Sebastian Krantz for raising an issue.Update copyright date in c files
Fix note on CRAN regarding SETLENGTH
"kit.nThread" is defined before setting it to 1LUpdate configure file to extend support for GCC
Correct warnings in NEWS.Rd (strong)
Correct typo in funique.Rd thanks to @davidbudzynski
Function pprod now returns double output even if inputs are integer - in line with base::prod - to avoid integer overflows.
Update configure file
Function pcountNA is equivalent to pcount(..., value = NA).
Function pcountNA and pcount(..., value = NA) allow NA counting with mixed data type (including data.frame). pcountNA also supports list-vectors as inputs and counts empty or NULL elements as NA.
Functions panyv, panyNA, pallv and pallNA are added as efficient wrappers around pcount and pcountNA. They are parallel equivalents of scalar functions base::anyNA and anyv, allv and allNA in the 'collapse' R package.
Functions pfirst and plast are added to efficiently obtain the row-wise first and last non-missing value or non-empty element of lists. They are parallel equivalents to the (column-wise) ffirst and flast functions in the 'collapse' R package. Implemented by @SebKrantz.
Functions psum/pprod/pmean also support logical vectors as input. Implemented by @SebKrantz.
charToFact was not returning proper results. Thanks to @alex-raw for raising an issue.Function pprod now returns double output even if inputs are integer - in line with base::prod - to avoid integer overflows.
C compiler warnings on CRAN R-devel caused by compilation with -Wstrict-prototypes are now fixed. Declaration of functions without prototypes is depreciated in all versions of C. Thanks to Sebastian Krantz for the PR.
pcount now supports data.frame.pcount now works with specific NA values, i.e. NA_real_, NA_character_ etc...psum, pmean, pprod, pany and pall now support lists. Thanks to Sebastian Krantz for the request and code suggestion.topn should now work for ALTREP object. Thanks to @ben-schwen for raising an issue.Function funique now preserves the attributes if the input is a data.table, tibble or similar objects. Thanks to Sebastian Krantz for the request.
Function topn now defaults to base R order for large value of n. Please see updated documentation for more information ?kit::topn.
Function charToFact gains a new argument addNA=TRUE to be used to include (or not) NA in levels of the output.
Function shareData, getData and clearData implemented to share data objects between R sessions. These functions are experimental and might change in the future. Feedback is welcome. Please see ?kit::shareData for more information.
Few calloc functions at C level have been replaced by R C API function Calloc to avoid valgrind errors/warnings in Travis CI.
Errors reported by rchk on CRAN have been fixed.
Function charToFact gains a new argument decreasing=FALSE to be used to order levels of the output in decreasing or increasing order.
Function topn gains a new argument index=TRUE to be used return index (TRUE) or values (FALSE) of input vector.
funique and psort on some platforms.pmean, pprod and psum will result in error if used with factors. Documentation has been updated.Function funique and fduplicated gain an additional argument fromLast=FALSE to indicate whether the search should start from the end or beginning PR#11.
Functions pall, pany, pmean, pprod and psum accept data.frame as input PR#15. Please see documentation for more information.
Function charToFact is equivalent to to base R as.factor but is much quicker and only converts character vector to factor. Note that it is parallelised. For more details and benchmark please see ?kit::charToFact.
Function psort is experimental and equivalent to to base R sort but is only for character vector. It can sort by "C locale" or by "R session locale". For more details and benchmark please see ?kit::psort.
A few OpenMP directives were missing for functions vswitch and nswitch for character vectors. These have been added in PR#12.
Function funique was not preserving attributes for character, logical and complex vectors/data.frames. Thanks to Sebastian Krantz (@SebKrantz) for bringing that to my attention. This has been fixed in PR#13.
Functions funique and uniqLen should now be faster for factor and logical vectors PR#14.
Function uniqLen(x) is equivalent to base R length(unique(x)) and uniqueN in package data.table. Function uniqLen, implemented in C, supports vectors, data.frame and matrix. It should be faster than these functions. For more details and benchmark please see ?kit::uniqLen.
Function vswitch now supports mixed encoding and gains an additional argument checkEnc=TRUE. Thanks to Xianying Tan (@shrektan) for the request and review PR#7.
Function nswitch is a nested version of function vswitch and also supports mixed encoding. Please see please see ?kit::nswitch for further details. Thanks to Xianying Tan (@shrektan) for the request and review PR#10.
Small algorithmic improvement for functions fduplicated, funique and countOccur for vectors, data.frame and matrix.
A tests folder has been added to the source package to track coverage and bugs.
nif has been split into two distinctive functions at C level, one has its arguments evaluated in a lazy way and is for R users and the other one (nifInternalR) is not lazy and is intended for usage at C level.Function countOccur(x), implemented in C, is comparable to base R function table. It returns a data.frame and is between 3 to 50 times faster. For more details, please see ?kit::countOccur.
Functions funique and fduplicated now support matrices. Additionally, these two functions should also have better performance compare to previous release.
Functions topn has an additional argument hasna=TRUE to indicates whether data contains NA value or not. If the data does not contain NA values, the function should be faster.
data.frame and matrix as well as do other operations. These functions are not exported or visible to the user but might become available and callable at C level in the future.Function fpos was not properly handling NaN and NA for complex and double. This should now be fixed. The function has also been changed in case the 'needle' and 'haysatck' are vectors so that a vector is returned.
Functions funique and fduplicated were not properly handling data containing POSIX data. This has now been fixed.
Functions fduplicated(x) and funique(x), implemented in C, are comparable to base R functions duplicated and unique. For more details, please see ?kit::funique.
Functions psum and pprod have now better performance for type double and complex.
Function count(x, y) now checks that x and y have the same class and levels. So does pcount.
Function pmean was not callable at C level because of a typo. This is now fixed.
Function count(x, value), implemented in C, to simply count the number of times an element value occurs in a vector or in a list x. For more details, please see ?kit::count.
Function pmean(..., na.rm=FALSE), pall(..., na.rm=FALSE), pany(..., na.rm=FALSE) and pcount(..., value), implemented in C, are similar to already available function psum and pprod. These functions respectively apply base R functions mean, all and any element-wise. For more details, benchmarks and help, please see ?kit::pmean.
Fix Solaris Unicode warnings for NEWS file. Benchmarks have been moved from the NEWS file to each function Rd file.
Fix some NA edge cases for pprod and psum so these functions behave more like base R function prod and sum.
Fix installation errors for version of R (<3.5.0).
Function fpos(needle, haystack, all=TRUE, overlap=TRUE), implemented in C, is inspired by base function which when used in the following form which(x == y, arr.ind =TRUE). Function fpos returns the index(es) or position(s) of a matrix/vector within a larger matrix/vector. Please see ?kit::fpos for more details.
Function iif(test, yes, no, na=NULL, tprom=FALSE, nThread=getOption("kit.nThread")), originally contributed as fifelse in package data.table, was moved to package kit to be developed independently. Unlike the current version of fifelse, iif allows type promotion like base function ifelse. For further details about the differences with fifelse, as well as hutils::if_else and dplyr::if_else, please see ?kit::iif.
Function nif(..., default=NULL), implemented in C, is inspired by SQL CASE WHEN. It is comparable to dplyr function case_when however it evaluates it arguments in a lazy way (i.e only when needed). Function nif was originally contributed as function fcase in the data.table package but then moved to package kit so its development may resume independently. Please see ?kit::nif for more details.
Function pprod(..., na.rm=FALSE) and psum(..., na.rm=FALSE), implemented in C, are inspired by base function pmin and pmax. These new functions work only for integer, double and complex types and do not recycle vectors. Please see ?kit::psum for more details.
Function setlevels(x, old, new, skip_absent=FALSE), implemented in C, may be used to set levels of a factor object. Please see ?kit::setlevels for more details.
Function topn(vec, n=6L, decreasing=TRUE), implemented in C, returns the top largest or smallest n values for a given numeric vector vec. It is inspired by dplyr::top_n and equivalent to base functions order and sort in specific cases as shown in the documentation. Please see ?kit::topn for more details.
Function vswitch(x, values, outputs, default=NULL, nThread=getOption("kit.nThread")), implemented in C, is a vectorised version of base R function switch. This function can also be seen as a particular case of function nif. Please see ?kit::switch for more details.