Is this what you're trying to do?

mtrx <- structure(c("BB", "AB", "BB", "BB", "BB", "BB", "AA", "BB", "BB", "BB", "BB", "BB", "AB", "AB", "BB", "AA", "BB", "BB", "BB", "BB", "BB", "AB", "BB", "BB", "BB"), .Dim = c(5L, 5L), .Dimnames = list( c("rs1", "rs2", "rs3", "rs4", "rs5"), c("LG_1", "LG_2", "LG_3", "LG_4", "LG_5")))

mtrx <- cbind(mtrx, dimnames(mtrx)[[1]])

write.table(mtrx, file ="set_a_2_format.tab",row.names = TRUE, col.names
            = TRUE, quote = FALSE)



Before saving simply cbind the row names onto the end of your matrix.


NM

On 2014-03-19 06:36, Ankush Sharma wrote:
HI all

How to add row names at the end of the record after transposing a matrix

Sample code
Data = read.table("set_a_2.txt",header = TRUE, sep = "\t")
Data.T <- t(Data[,0:ncol(fooData)])
write.table(Data.T, file ="set_a_2_format.tab",row.names = TRUE, col.names
= TRUE, quote = FALSE)


 example of Transposed matrix
class  rs1 rs2 rs3 rs4 rs5
LG_1 BB AB BB BB BB
LG_2 BB AA BB BB BB
LG_3 BB BB AB AB BB
LG_4 AA BB BB BB BB
LG_5 BB AB BB BB BB

how can i add row headers (LG_1) at the end of rows also

Regards,
Ankush Sharma

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to