formatmatrix {AGHmatrix} | R Documentation

## Transform a matrix in 3 columns

### Description

Given any square matrix transform it in a 3 columns way (row, column, value) mainly to be used in outsourcing data processing (as ASREML-standalone)

### Usage

    formatmatrix(data = NULL, save = TRUE, return = FALSE,
      name = deparse(substitute(data)), round.by = 12, exclude.0 = TRUE)

### Arguments

`data` | matrix (nxn).
`save` | if TRUE save the output in a file. Default=TRUE.
`return` | if TRUE return the output in a object. Default=FALSE.
`name` | name of the csv file to be saved. Default=data name.
`round.by` | select the number of digits after 0 you want in your data. Default = 12
`exclude.0` | if TRUE, remove all lines equal to zero (ASREML option). Default = TRUE

### Value

a object or a csv file with a table with 3 columns representing the matrix.

### Author(s)

Rodrigo R Amadeu, rramadeu@gmail.com

### Examples

    #Example with random matrix
    data<-matrix(c(1,0.1,0,0.1,1,0,0,0,1.1),3)
    formatmatrix(data=data,save=FALSE,return=TRUE,exclude.0=TRUE)

    #Example with pedigree matrix
    #Reading the example data
    data(ped.mrode)
    #Making Relationship Matrix
    Amrode<-Amatrix(ped.mrode)
    #Inverting the Matrix
    Amrode.inv<-solve(Amrode)
    #Making the 3 columns format
    Amrode.inv.ASREML<-formatmatrix(Amrode,save=FALSE,return=TRUE,exclude.0=TRUE)
    #Printing it
    Amrode.inv.ASREML

[Package AGHmatrix version 1.0.2 Index]