Description Usage Arguments Value Author(s) See Also Examples
Function to convert a x*y matrix to a x*y by 3 data frame with columns x, y and as.vector(matrix).
1 2 3 | Matrix2DataFrame(mat,
x=NULL,y=NULL,
xlab="x",ylab="y",zlab="z")
|
mat |
Matrix to convert to a data frame. |
x,y |
Vectors of x and y coordinates. Must be of dimension dim(mat)[1] ou dim(mat)[2]. If NULL, x=0:dim(mat)[1]-1 and y=0:dim(mat)[2]-1. |
xlab, ylab, zlab |
Character string, labels of the columns of the new data frame. |
Return a data frame of dimension x*y by 3 data frame containing an expansion of mat as a data frame.
Vincent Le Bourlot
expand.grid
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
# Define a 2 by 3 matrix
mat=matrix(1:6,2,3)
# Convert to a 6 by 3 data frame
Matrix2DataFrame(mat)
# Define values for x and y
Matrix2DataFrame(mat,x=1:2,y=c("a","b","c"))
# If x and y are inverted
Matrix2DataFrame(mat,x=c("a","b","c"),y=1:2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.