Fast data manipulation functions implemented in C for large datasets. Provides vectorized alternatives to base R functions with significant performance improvements.
# From CRAN
install.packages("kit")
# Development version
install.packages("kit", repos = "https://fastverse.r-universe.dev")
Vector-valued functions operating in parallel over vectors or data frames:
psum, pprod, pmean: Parallel sum, product, and meanfpmin, fpmax, prange: (Fast) parallel minimum, maximum, and rangepall, pany: Parallel all/any operationspcount, pcountNA: Count occurrences of values or NAspfirst, plast: First/last non-missing valuesx <- c(1, 3, NA, 5)
y <- c(2, NA, 4, 1)
psum(x, y, na.rm = TRUE) # [1] 3 3 4 6
pmean(x, y, na.rm = TRUE) # [1] 1.5 3.0 4.0 3.0
fpmin(x, y, na.rm = TRUE) # [1] 1 3 4 1
fpmax(x, y, na.rm = TRUE) # [1] 2 3 4 5
prange(x, y, na.rm = TRUE) # [1] 1 0 0 4
Fast vectorized conditional logic:
iif: Fast replacement for ifelse() with attribute preservationnif: Nested if-else (SQL CASE WHEN equivalent)vswitch, nswitch: Vectorized switch statementsiif(x > 2, x, x - 1) # Preserves attributes unlike base::ifelse
nif(x == 1, "one", x == 2, "two", default = "other")
psort: Parallel sort for character vectorstopn: Efficient partial sort (top N values) without full sortingtopn(x, n = 6L, decreasing = TRUE) # Much faster than order()[1:6]
charToFact: Fast character-to-factor conversionsetlevels: Change factor levels by referencefunique, fduplicated: Fast unique/duplicated operationsuniqLen: Fast equivalent to length(unique(x))
count, countNA, countOccur: Count element occurrencesfunique(iris$Species) # Faster than base::unique
uniqLen(iris$Species) # Faster than length(unique())
fpos: Find matrix/vector positions within larger structuresshareData, getData, clearData: Share data between R sessionsFull documentation available at: https://fastverse.org/kit/
GPL-3