% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_valL.R
\name{get_valL}
\alias{get_valL}
\alias{put_valL<-}
\title{Get Values from a List Consisting of Data Frames}
\usage{
get_valL(L, s1 = NULL, s2 = NULL, s3 = NULL, simplify = 1)

put_valL(L, s1 = NULL, s2 = NULL, s3 = NULL) <- value
}
\arguments{
\item{L}{A list of data frames}

\item{s1}{Vector consisting of the subscripts for the 1st dimension}

\item{s2}{Vector consisting of the subscripts for the 2nd dimension}

\item{s3}{Vector consisting of the subscripts for the 3rd dimension}

\item{simplify}{= 0 to leave the result of get_valL unsimplified (list)}

\item{value}{The value to be assigned. Either a vector or a matrix.}
}
\value{
\code{get_valL(L, s1,s2,s3)} returns
 \code{(s1,s2)} element(s) of the s3-th data frame(s). \cr
 \code{put_valL(L, s1,s2,s3) <- value} replaces the \code{s1,s2}
 element(s) of the data frame(s) specified by \code{s3}
 with \code{value}.
}
\description{
Get Values from a List Consisting of Data Frames
}
\details{
It is assumed that \code{L} is a list consisting of several data frames.
and the third subscript, \code{s3} is for the list.\cr
Therefore, \code{get_valL(L,,,s3)} with scalar s3 is
equivalent to \code{L[[s3]]} \cr
and  \code{get_valL(L,,,2:3)} returns the 2nd and the 3rd data frames
in a list. \cr

\code{s1,s2,s3} can be a set of vectors consisting of row/col/list names.

\cr
When some of the subscripts are out of range, only the valid ones
will be used.

\cr
The result will be simplified to a matrix or vector if possible. \cr
When \code{length(s1)==1}, the result will be
a \code{length(L)} x \code{ncol(L[[1]])} matrix. \cr
When \code{length(s2)==1}, the result will be
a \code{ncol(L[[1]])} x \code{length(L)} matrix. \cr
}
\examples{
L0 <- list( A=data.frame(demomat(3,2)*10+1)
          , B=data.frame(demomat(4,3)*10+2)
          , C=data.frame(demomat(5,4)*10+3)
         )
L <- L0
get_valL( L, ,,2 ) # should be equal to get_valL( L, ,,"B" )
get_valL( L, 2, )  # should be equal to get_valL( L, "r2",, )
get_valL( L, ,2 )  # should be equal to get_valL( L, , "c2", )
get_valL( L, c(1,3),,3:2 )
get_valL( L, c(1,3),, c("B","A") )

L <- L0; put_valL(L, 1:2,1:2,3) <- 0;                  Print(L)
L <- L0; put_valL(L, 1:2,1:2,c("C","A")) <- 0;         Print(L)
L <- L0; put_valL(L, 3:5,2:4,) <- 0;                   Print(L)
L <- L0; put_valL(L, 3:5,2:4,2) <- 0;                  Print(L)
L <- L0; put_valL(L, 1:4,1,2:3) <- 1:4;                Print(L)
L <- L0; put_valL(L, 1:2,2:3,2:3) <- demomat(2,2)*100; Print(L)

# effect of simplify
L0 <- list( A=data.frame(demomat(3,4)*10+1)
          , B=data.frame(demomat(3,4)*10+2)
          , C=data.frame(demomat(3,4)*10+3)
         )
L <- L0
get_valL( L, ,,2 )
get_valL( L, ,,2, simplify=0 )
get_valL( L, 2, )
get_valL( L, 2,, simplify=0 )
get_valL( L, ,2 )
get_valL( L, ,2, simplify=0 )

# When the selected elements are scalars, the result is a column vector.
get_valL(L0,1:2,1) # matrix
get_valL(L0,1,1)   # col vector
get_valL(L0,1,1:2) # matrix

# mixed type variables in a data frame
A <- data.frame(demomat(3,4)*10+1)
A[,2] <- paste("c",as.character(A[,2]),sep="")
B <- data.frame(demomat(3,4)*10+2)
B[,2] <- paste("c",as.character(B[,2]),sep="")
C <- data.frame(demomat(3,4)*10+3)
C[,2] <- paste("c",as.character(C[,2]),sep="")
L <- list(A=A,B=B,C=C)

get_valL( L, 2, )
get_valL( L, , 2 )


}
