R/utilities.R

Defines functions FirstLower changenull nullToNA

# hidden
nullToNA <- function(x) {
  x[sapply(x, is.null)] <- NA
  return(x)
}
changenull <- function(x, to = ""){
  ifelse(is.null(x),to,x)
}

# hidden
insectbraindb_progress <- function (x, max = 100, message = "querying insectbraindb") {
  percent <- x / max * 100
  cat(sprintf('\r|%-50s| ~%d%% %s',
              paste(rep('+', percent / 2), collapse = ''),
              floor(percent), message))
  if (x == max)
    cat('\n')
}

# hidden
FirstLower <- function(x) {
  s <- strsplit(x, " ")[[1]]
  paste(tolower(substring(s, 1,1)), substring(s, 2),
        sep="", collapse=" ")
}
natverse/insectbrainr documentation built on Jan. 29, 2020, 5:48 p.m.