R/call.R

Defines functions psort .onUnload .onLoad .onAttach vswitch uniqLen topn setlevels psum pprod pmean pcount pany pall nswitch nif iif funique fpos fduplicated countOccur countNA count charToFact

Documented in charToFact count countNA countOccur fduplicated fpos funique iif iif nif nswitch pall pany pcount pmean pprod psort psum setlevels topn uniqLen vswitch

# Function calls
charToFact  = function(x, decreasing=FALSE, nThread=getOption("kit.nThread")) .Call(CcharToFactR, x, decreasing, nThread, NA, parent.frame())
count       = function(x, value) .Call(CcountR, x, value)
countNA     = function(x) .Call(CcountNAR, x)
countOccur  = function(x) .Call(CcountOccurR, x)
fduplicated = function(x, fromLast = FALSE) .Call(CdupR, x, FALSE, fromLast)
fpos        = function(needle, haystack, all=TRUE, overlap=TRUE) .Call(CfposR, needle, haystack, all, overlap)
funique     = function(x, fromLast = FALSE) .Call(CdupR, x, TRUE, fromLast)
iif         = function(test, yes, no, na=NULL, tprom=FALSE, nThread=getOption("kit.nThread")) .Call(CiifR, test, yes, no, na, tprom, nThread)
nif         = function(..., default=NULL) .Call(CnifR, default, parent.frame(), as.list(substitute(...())))
nswitch     = function(x, ..., default=NULL, nThread=getOption("kit.nThread"), checkEnc = TRUE) .Call(CnswitchR, x, default, nThread, checkEnc, list(...))
pall        = function(..., na.rm=FALSE) .Call(CpallR, na.rm, if (length(a <- list(...)) == 1 && is.data.frame(a[[1]])) a[[1]] else a)
pany        = function(..., na.rm=FALSE) .Call(CpanyR, na.rm, if (length(a <- list(...)) == 1 && is.data.frame(a[[1]])) a[[1]] else a)
pcount      = function(..., value) .Call(CpcountR, value, list(...))
pmean       = function(..., na.rm=FALSE) .Call(CpmeanR, na.rm, if (length(a <- list(...)) == 1 && is.data.frame(a[[1]])) a[[1]] else a)
pprod       = function(..., na.rm=FALSE) .Call(CpprodR, na.rm, if (length(a <- list(...)) == 1 && is.data.frame(a[[1]])) a[[1]] else a)
psum        = function(..., na.rm=FALSE) .Call(CpsumR,  na.rm, if (length(a <- list(...)) == 1 && is.data.frame(a[[1]])) a[[1]] else a)
setlevels   = function(x, old = levels(x), new, skip_absent=FALSE) invisible(.Call(CsetlevelsR, x, old, new, skip_absent))
topn        = function(vec, n=6L, decreasing=TRUE, hasna=TRUE,index=TRUE) if(index) .Call(CtopnR, vec, n, decreasing, hasna) else vec[.Call(CtopnR, vec, n, decreasing, hasna)]
uniqLen     = function(x) .Call(CdupLenR, x)
vswitch     = function(x, values, outputs, default=NULL, nThread=getOption("kit.nThread"), checkEnc = TRUE) .Call(CvswitchR, x, values, outputs, default, nThread, checkEnc)

.onAttach   = function(libname, pkgname) packageStartupMessage(paste0("Attaching kit 0.0.7 (OPENMP ",if(.Call(CompEnabledR)) "enabled" else "disabled"," using 1 thread)"))
.onLoad     = function(libname, pkgname) options("kit.nThread"=1L)   #nocov
.onUnload   = function(libpath) library.dynam.unload("kit", libpath) #nocov

psort = function(x, decreasing = FALSE, na.last = NA, nThread=getOption("kit.nThread"), c.locale = TRUE) {
  if (typeof(x) == "character") {
    return(.Call(CcpsortR, x, decreasing, nThread, na.last,parent.frame(), FALSE, c.locale))
  }
  warning("Function 'psort' was only implemented for character vectors. Defaulting to base::sort.")
  sort(x, decreasing = decreasing, na.last = na.last,method = if(c.locale) "radix" else "quick")
}

Try the kit package in your browser

Any scripts or data that you put into this service are public.

kit documentation built on March 9, 2021, 5:12 p.m.