
Last chance! 50% off unlimited learning
Sale ends in
data.matrix(frame, rownames.force = NA)
NULL
)
rownames
. The default, NA
, uses NULL
rownames if the data frame has ‘automatic’ row.names or for a
zero-row data frame.frame
inherits from class "data.frame"
, an integer or
numeric matrix of the same dimensions as frame
, with dimnames
taken from the row.names
(or NULL
, depending on
rownames.force
) and names
.Otherwise, the result of as.matrix
.
is.numeric
) is
converted by as.numeric
or, for S4 objects,
as(, "numeric")
. If all columns are integer (after
conversion) the result is an integer matrix, otherwise a numeric
(double) matrix.
as.matrix
,
data.frame
,
matrix
.
DF <- data.frame(a = 1:3, b = letters[10:12],
c = seq(as.Date("2004-01-01"), by = "week", len = 3),
stringsAsFactors = TRUE)
data.matrix(DF[1:2])
data.matrix(DF)
Run the code above in your browser using DataLab