Learn R Programming

AMModels (version 0.1.4)

methods-amModelLib: Methods For Displaying, Summarizing, And Manipulating amModelLib Objects

Description

Getters and setters for AMModelLib objects.

Usage

# S4 method for amModelLib
summary(object, name, ...)

# S4 method for amModelLib show(object)

# S4 method for amModelLib c(x, ..., recursive = FALSE)

# S4 method for amModelLib,ANY,ANY,ANY [(x, i, j, ..., drop = TRUE)

# S4 method for amModelLib,ANY,ANY [[(x, i)

# S4 method for amModelLib $(x, name)

# S4 method for amModelLib,ANY,ANY [[(x, i, j, ...) <- value

Arguments

object

An amModelLib object.

name

For $ A literal character string or a name (possibly backtick quoted); for summary an amModel or amData name as character string.

Additional arguments passed to other functions or methods.

x

An amModelLib object.

recursive

Iterate recursively through lists (ignored).

i, j

indices specifying elements to extract or replace. Indices are numeric or character vectors or empty (missing) or NULL.

drop

Not used.

value

Replacement value.

Value

summary returns a list with the same elements displayed during the call. Others return an amModelLib object.

Details

Summary adds the metadata to the default show method. If name is supplied the call is passed on to the amModel or amData object with the specified name.

Examples

Run this code
# NOT RUN {
# create dataset from lm helpfile
## Annette Dobson (1990) "An Introduction to Generalized Linear Models".
## Page 9: Plant Weight Data.
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
weight <- c(ctl, trt)
lm.D9 <- lm(weight ~ group)
lm.D90 <- lm(weight ~ group - 1) # omitting intercept

#' # create an amData object that includes metadata
plant.data <- data.frame(group = group, weight = weight)
plant.data <- amData(
    data = plant.data, 
    comment = 'Dataset from lm helpfile.'
)

log.plant.data <- data.frame(group, log.weight=log(weight))
log.plant.data <- amData(
    data = log.plant.data, 
    comment = 'data to fit log model', 
    source = 'lm helpfile (R).'
)

# create two amModel objects with metadata and a soft link to the data
full.model <- amModel(
    model = lm.D9, 
    comment = 'full model', 
    source = 'lm helpfile (R).', 
    taxa = 'plants', 
    data = 'plant.data'
)

no.int.model <- amModel(
    model = lm.D90, 
    comment = 'model without intercept', 
    source = 'lm helpfile (R).', 
    taxa = 'plants', 
    data = 'plant.data'
)



# create an amModelLib that contains the two amModel objects and two amData objects
# the models and data must be supplied as named lists
mymodels <- amModelLib(
    models = list(
        full.model = full.model, 
        no.int.model = no.int.model
    ), 
    data=list(
        plant.data = plant.data, 
        log.plant.data = log.plant.data
    )
)

summary(mymodels)
mymodels <- c(mymodels, mymodels)
mymodels[c(2,1)]
mymodels[[1]]
mymodels[['full.model']]
mymodels$full.model
# }

Run the code above in your browser using DataLab