R/log_factorial.R

log_factorial <- function(x) {
  m <- apply(x, c(1, 2), function(t)
    if (is.na(t)) {
      NA
    } else if (t == 0) {
      1
    } else
      sum(log(1:t)))
  return(m)
}

Try the mimi package in your browser

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

mimi documentation built on May 2, 2019, 10:59 a.m.