formatmatrix: Transform a matrix in 3 columns

Description Usage Arguments Value Author(s) Examples

View source: R/formatmatrix.R

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

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#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 

AGHmatrix documentation built on July 31, 2019, 1:04 a.m.