The R Project SVN R

Rev

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

Rev 68948 Rev 76937
Line 1... Line 1...
1
% File src/library/base/man/data.matrix.Rd
1
% File src/library/base/man/data.matrix.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2008 R Core Team
3
% Copyright 1995-2019 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{data.matrix}
6
\name{data.matrix}
7
\alias{data.matrix}
7
\alias{data.matrix}
8
\title{Convert a Data Frame to a Numeric Matrix}
8
\title{Convert a Data Frame to a Numeric Matrix}
Line 15... Line 15...
15
\usage{
15
\usage{
16
data.matrix(frame, rownames.force = NA)
16
data.matrix(frame, rownames.force = NA)
17
}
17
}
18
\arguments{
18
\arguments{
19
  \item{frame}{a data frame whose components are logical vectors,
19
  \item{frame}{a data frame whose components are logical vectors,
20
    factors or numeric vectors.}
20
    factors or numeric or character vectors.}
21
  \item{rownames.force}{logical indicating if the resulting matrix
21
  \item{rownames.force}{logical indicating if the resulting matrix
22
    should have character (rather than \code{NULL})
22
    should have character (rather than \code{NULL})
23
    \code{\link{rownames}}.  The default, \code{NA}, uses \code{NULL}
23
    \code{\link{rownames}}.  The default, \code{NA}, uses \code{NULL}
24
    rownames if the data frame has \sQuote{automatic} row.names or for a
24
    rownames if the data frame has \sQuote{automatic} row.names or for a
25
    zero-row data frame.}
25
    zero-row data frame.}
26
}
26
}
27
\details{
27
\details{
28
  Logical and factor columns are converted to integers.  Any other
28
  Logical and factor columns are converted to integers.  Character
-
 
29
  columns are first converted to factors and then to integers. Any other
29
  column which is not numeric (according to \code{\link{is.numeric}}) is
30
  column which is not numeric (according to \code{\link{is.numeric}}) is
30
  converted by \code{\link{as.numeric}} or, for S4 objects,
31
  converted by \code{\link{as.numeric}} or, for S4 objects,
31
  \code{\link{as}(, "numeric")}.  If all columns are integer (after
32
  \code{\link{as}(, "numeric")}.  If all columns are integer (after
32
  conversion) the result is an integer matrix, otherwise a numeric
33
  conversion) the result is an integer matrix, otherwise a numeric
33
  (double) matrix.
34
  (double) matrix.