getListElement {BMisc}R Documentation

Return Particular Element from Each Element in a List

Description

a function to take a list and get a particular part out of each element in the list

Usage

getListElement(listolists, whichone = 1)

Arguments

listolists

a list

whichone

which item to get out of each list (can be numeric or name)

Value

list of all the elements 'whichone' from each list

Examples

len <- 100 # number elements in list
lis <- lapply(1:len, function(l) list(x=(-l), y=l^2) ) # create list
getListElement(lis, "x")[1] # should be equal to -1
getListElement(lis, 1)[1] # should be equal to -1


[Package BMisc version 1.4.6 Index]