R/rules.R

maxrule <- function (x) {

  xx <- as.numeric(x)
  if (any(is.na(xx))) {	
    xx <- na.omit(suppressWarnings(as.numeric(unlist(strsplit(unlist(strsplit(x, "-"), use.names = FALSE), " "), use.names = FALSE))))
  }

  max(xx)
  
}


intervalrule <- function (x, revert = FALSE) {

  xx <- na.omit(suppressWarnings(as.numeric(unlist(strsplit(x, "-"), use.names = FALSE))))

  # Revert the series around before calculation
  if (revert) {
    xx <- rev(xx)
  }
  
  max(xx) - min(xx) + 1

}
rOpenGov/bibliographica documentation built on April 10, 2022, 8:51 p.m.