R/has.interaction.R

Defines functions has.interaction

Documented in has.interaction

#' Function has.interaction checks whether x is part of a term in terms. Original code at: http://stackoverflow.com/questions/19226816/how-can-i-view-the-source-code-for-a-function. Some changes have been done.
#' 
#' @param x a logistic model (an object of class "glm", usually, a result of a call to glm).
#' @param terms is a vector with names of terms from a model.
#' @return Logical. TRUE if an interaction is a term in terms. Otherwise is FALSE.
has.interaction <- function(x,terms){
  out <- sapply(terms,function(i){
    sum(1-(strsplit(x,":")[[1]] %in% strsplit(i,":")[[1]]))==0
  })
  return(sum(out)>0)
}
IRBLleida/UdBRpackage documentation built on Dec. 24, 2019, 9:10 p.m.