Learn R Programming

PSEA (version 1.6.0)

slt: Extracts from a list of objects

Description

Simple wrapper to extract a particular slot for each object in a list.

Usage

slt(ls,slot,index=NULL)

Arguments

ls
list of objects.
slot
character. Name of the slot to extract.
index
integer vector. Optional index vector to extract only a subset of the elements contained in the slot.

Value

sc
vector or matrix.

Details

The slot to be extracted is defined by matching "slot" against slot names of the first object in the list.

Slot extraction is done with sapply and the format of the output will depend on the content of the slots (see the value returned by sapply for details).

Examples

Run this code
## Two arbitrary regression summaries in a list
x<-1:10
y1 <- x + rnorm(10,sd=1)
y2 <- x + rnorm(10,sd=5)

slm<-list()
slm[[1]] <- summary(lm(y1 ~ x))
slm[[2]] <- summary(lm(y2 ~ x))

## Extract R-squared from the list of summary.lm objects
slt(slm, "adj.r.squared")

Run the code above in your browser using DataLab