R/tableWithoutSort.R

Defines functions tableWithoutSort

tableWithoutSort <- function(x,exclude = NA) {
  tab <- table(x,exclude=exclude)
  u <- unique(x)
  if (any(is.na(u))) {
    u <- u[!is.na(u)]
    ustr <- as.character(u)
    count <- tab[ustr]
    count <- c(count,tab[is.na(names(tab))])
  } else {
    ustr <- as.character(u)
    #count <- tab[ustr]  
    count <- tab[match(ustr,names(tab))]  
  }
  names(dimnames(count)) <- NULL
  count
}

Try the vtree package in your browser

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

vtree documentation built on Dec. 11, 2022, 1:05 a.m.