The R Project SVN R-packages

Rev

Rev 155 | Rev 2208 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 155 Rev 1013
Line 3... Line 3...
3
\title{Construct a Classed Matrix}
3
\title{Construct a Classed Matrix}
4
\usage{
4
\usage{
5
Matrix(data=NA, nrow=1, ncol=1, byrow=FALSE, dimnames=NULL)
5
Matrix(data=NA, nrow=1, ncol=1, byrow=FALSE, dimnames=NULL)
6
}
6
}
7
\description{
7
\description{
8
    Construct a Matrix of a class that inherits from \code{Matrix}.
8
  Construct a Matrix of a class that inherits from \code{Matrix}.
9
}
9
}
10
\arguments{
10
\arguments{
11
  \item{data}{an optional numeric data vector or matrix.}
11
  \item{data}{an optional numeric data vector or matrix.}
12
  \item{nrow}{the desired number of rows}
12
  \item{nrow}{the desired number of rows}
13
  \item{ncol}{the desired number of columns}
13
  \item{ncol}{the desired number of columns}
14
  \item{byrow}{logical. If \code{FALSE}
14
  \item{byrow}{logical.  If \code{FALSE} (the default) the matrix is
15
    (the default) the matrix is filled by columns, otherwise the matrix is
15
    filled by columns, otherwise the matrix is filled by rows.}
16
    filled by rows.}
-
 
17
  \item{dimnames}{A \code{\link{dimnames}} attribute for the matrix: a
16
  \item{dimnames}{a \code{\link{dimnames}} attribute for the matrix: a
18
    \code{list} of length 2.}
17
    \code{list} of two character components.}
19
}
18
}
20
\value{
19
\value{
21
    Returns an \code{nrow} by \code{ncol} matrix of a class that
20
  Returns an \code{nrow} by \code{ncol} matrix of a class that
22
    inherits from \code{"Matrix"}. 
21
  inherits from \code{"Matrix"}.
23
}
22
}
24
\details{
23
\details{
25
    If either of \code{nrow} or \code{ncol} is
24
  If either of \code{nrow} or \code{ncol} is not given, an attempt is
26
    not given, an attempt is made to infer it from the length of
25
  made to infer it from the length of \code{data} and the other
27
    \code{data} and the other parameter.
26
  parameter.
28
 
27
 
29
    Although it is sometime possible to mix unclassed matrices (created
28
  Although it is sometime possible to mix unclassed matrices (created
30
    with \code{matrix}) with ones of class \code{"Matrix"}, it is much
29
  with \code{matrix}) with ones of class \code{"Matrix"}, it is much
31
    safer to always use carefully constructed ones of class
30
  safer to always use carefully constructed ones of class
32
    \code{"Matrix"}.
31
  \code{"Matrix"}.
33
}
32
}
34
\seealso{
33
\seealso{
35
    \code{\link{matrix}}.
34
  \code{\link{Matrix-class}}; \code{\link{matrix}}.
36
}
35
}
37
\examples{
36
\examples{
38
Matrix(0, 3, 2)             # a 3 by 2 matrix of zeros
37
Matrix(0, 3, 2)             # a 3 by 2 matrix of zeros
39
Matrix(1:6, 3, 2)           # a 3 by 2 matrix
38
Matrix(1:6, 3, 2)           # a 3 by 2 matrix
40
Matrix(1:6, nrow=3)   
39
Matrix(1:6, nrow=3)
41
Matrix(1:6, ncol=2)   
40
Matrix(1:6, ncol=2)
-
 
41
Matrix(1:9, nrow=3,
42
Matrix(1:9, nrow=3, dimnames =list(c("a", "b", "c"), c("A", "B", "C")))
42
       dimnames = list(c("a", "b", "c"), c("A", "B", "C")))
43
}
43
}
44
\keyword{array}
44
\keyword{array}
45
\keyword{algebra}
45
\keyword{algebra}