get_valLL {lazy.tools}R Documentation

Get Elements Contained in the Lists in a List

Description

Get Elements Contained in the Lists in a List

Usage

get_valLL(L, name, removenull = 0, simplify = 1)

Arguments

L

A list of lists

name

The name of the list element, or the element number

removenull

= 1 to remove NULL elements

simplify

= 0 to leave the result of get_valLL unsimplified (list)

Details

It is assumed that L is a list consisting of several lists which contain the same objects.

If simplify=1 is given, the result will be converted to a data frame or matrix if possible.

If the lists contain lists or arrays, the result will not be simplified.

Try l2a( lapply( "get_valLL result", a2m, method=2 ) ) .

If removenull=1 is given, and name is not valid, NULL or named list() may be returned.

If the list consists of data frames only, better use get_valL.

Value

A list or data frame consisting of the specified elements.

Examples

library(lazy.tools)
L0 <- list( A=(demomat(3,2)*10+1)
            , B=data.frame(demomat(4,3)*10+2)
            , C=data.frame(demomat(5,4)*10+3)
)
L00 <- list( A=(demomat(3,2)*100+1)
             , B=data.frame(demomat(4,3, root="b"))
             , C=(demomat(5,4, root="c"))
             , D=(demomat(5,4, root="d"))
)
L000 <- list( A=(demomat(3,2)*1000+1)
              , B=(1:3)*1000+2
              , C2=(demomat(5,4)*1000+3)
              , D=(demomat(4,5)*1000+4)
)
L <- list(L0,L00,L000)
names(L) <- c("a","b","c")

get_valLL( L,"A"  ) #   This is a matrix.
get_valLL( L,"A", simplify=0  ) #   This is a list.
get_valLL( L,"B" ) #   This is a data frame.
get_valLL( L,"B", simplify=0 ) #   This is a list.
get_valLL( L, 4 ) # n_u_l_l indicates missing elements.
get_valLL( L, 4, simplify=0  ) # NULL indicates missing elements.
get_valLL( L, 4, removenull=1  ) # missing elements were removed.
get_valLL( L, 4, simplify=0, removenull=1  ) # a list.


[Package lazy.tools version 0.1.3 Index]