Matrix2DataFrame: Function to convert a matrix to a data frame.

Description Usage Arguments Value Author(s) See Also Examples

Description

Function to convert a x*y matrix to a x*y by 3 data frame with columns x, y and as.vector(matrix).

Usage

1
2
3
Matrix2DataFrame(mat,
                 x=NULL,y=NULL,
                 xlab="x",ylab="y",zlab="z")

Arguments

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.

Value

Return a data frame of dimension x*y by 3 data frame containing an expansion of mat as a data frame.

Author(s)

Vincent Le Bourlot

See Also

expand.grid

Examples

 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)

STdiag documentation built on May 2, 2019, 4:58 p.m.