formatmatrix {AGHmatrix} | R Documentation |
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)
formatmatrix(data = NULL, save = TRUE, return = FALSE, name = deparse(substitute(data)), round.by = 12, exclude.0 = TRUE)
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 |
a object or a csv file with a table with 3 columns representing the matrix.
Rodrigo R Amadeu, rramadeu@gmail.com
#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