Learn R Programming

dynamicGraph (version 0.1.6.6)

newDefaultTestObject: The test object

Description

Returns an object of the class defaultTestObjectProto.

Usage

newDefaultTestObject(name)

Arguments

name
Text string with the name of the test object.

Value

  • An object of class defaultTestObjectProto.

Details

The methods label and width should be implemented by you for your test object returned by the method testEdge of your object.

See Also

newDefaultModelObject

Examples

Run this code
setClass("defaultTestObjectProto", 
         representation(deviance = "numeric", df = "numeric", p = "numeric"))

"newDefaultTestObject"<-
  function(name)
  {
    df <- round(runif(1, 1, 25))
    message("Just generating a random test!!!!!")
    deviance <- rchisq(1, df)
    p <- 1 - pchisq(deviance, df)
    result <- new("defaultTestObjectProto",
                   df = df, deviance = deviance, p = p)
    return(result)
  }

if (!isGeneric("label") && !isGeneric("label", where = 2)) {
  if (is.function("label"))
    fun <- label
  else
    fun <- function(object) standardGeneric("label")
  setGeneric("label", fun)
}

setMethod("label", "defaultTestObjectProto",
          function(object) format(object@p, digits = 4))

if (!isGeneric("width") && !isGeneric("width", where = 2)) {
  if (is.function("width"))
    fun <- width
  else
    fun <- function(object) standardGeneric("width")
  setGeneric("width", fun)
}

setMethod("width", "defaultTestObjectProto",
          function(object) round(2 + 5 * (1 - object@p)))


newDefaultTestObject("TestObject")

Run the code above in your browser using DataLab