slt: Extracts from a list of objects

Description Usage Arguments Details Value Author(s) Examples

View source: R/slt.R

Description

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

Usage

1
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.

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).

Value

sc

vector or matrix.

Author(s)

Alexandre Kuhn alexandre.m.kuhn@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 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")

alexandremkuhn/PSEA documentation built on March 26, 2020, 12:04 a.m.