R/addVariable.R

addVariable <- function (lm, data, model, id){
  if (!is.na(match(model, listModels)))
  {
    augData <- augmentedData(data)
    if (length(lm) == 0)
    {
      show("lm = 0")
      lm[[1]] <- new("MixtureModel",
                     augData,
                     model,
                     id,
                     "double")
    }
    else
    {
      if (length(lm[[1]]@augData$data) == length(augData$data))
      {
        show("lm > 0")
        lm[[length(lm)+1]] <- new("MixtureModel",
                                  augData,
                                  model,
                                  id,
                                  "double")
      }
      else
      {
        message( "New variable has "
               , length(augData$data)
               , " samples while the data currently in the mixture has "
               , length(lm[[1]]["data"]) # comparison with the size of the data in the first model, first column
               , " samples. New variable has not been added.")
      }
    }
  }
  else
  {
    message("Model ", model, " is not yet supported. New variable has not been added.")
  }
  return(lm)
}

Try the RMixtComp package in your browser

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

RMixtComp documentation built on May 2, 2019, 5:16 p.m.