insertAMModelLib {AMModels}R Documentation

Insert Model Of Class amModel Or Dataset Of Class amData Into An amModelLib Object


Inserts a model into the model slot of an amModelLib object, or inserts a dataset into the data slot of an amModelLib object. If the amModelLib is not specified, the function will create an info-less and description-less lib – or specify these components in the ... argument.


insertAMModelLib(models, data, amml, ...)



A named list of amModel objects, each composed of a fitted model object and metadata.


An object of class amData.


The name of the object that of class amModelLib.


Additional arguments to be passed to the function amModelLib to be included in the amModelLib if one is created.


If the argument amml is NULL, the function will call amModelLib to create the object. The argument info can be passed to this function via the ... argument.


An object of class amModelLib

See Also

Other amModelLib: AMModels, amData, amModelLib, amModel, getters, grepAMModelLib, lsModels, rmModel


# 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 <- data.frame(group = group, weight = weight) <- amData(data =, comment = 'Dataset from lm helpfile.')

# create an amModel object 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 = ''

# create an amModelLib that contains the amModel object and the amData object
# the model and data must be supplied as named lists
mymodels <- amModelLib(
    description = "An example amModelLib.",
    models = list(full.model = full.model), 
    data = list( =
# create second amModel object with metadata and a soft link to the same data <- amModel(
    model = lm.D90, 
    comment = 'model without intercept', 
    source = 'lm helpfile (R).', 
    taxa = 'plants', 
    data = ''

# create a second amData object <- data.frame(group, log.weight=log(weight)) <- amData(
    data =, 
    comment = 'data to fit log model', 
    source = 'lm helpfile (R).'

# insert the second model and second dataset to the amModelLib
mymodels <- insertAMModelLib(
    models = list( =,
    data = list( =

[Package AMModels version 0.1.4 Index]