Friday, 15 July 2011

How to export matrix modified with matsplitter in R -


I need to export a * .txt file from R to a matrix that split without losing format with matislitzer function Has been made, ie I need data in a subset of three rows and five columns.

matspliltter function:

  matsplitter & lt; -function (m, r, c) {rg & lt; - (row (m) -1)% /% r + 1 CG & lt; - (Call (M) -1)% /% C + 1 RCI and LT; - (RG-1) * Maximum (CG) + CG N & T - Prod (Dim (M)) / R / C CV & lt; - unlist (loop (1: n, function (x) m [rcI == x] dim (cv) & lt; -c (r, c, n) cv}  

Example matrix, partition, and output

  B <- Matrix (c (1: 1380), ncol = 5) matsplitter (B, 3,5) write.table (B, File = "Outfile.txt", sep = "\ t", col.names = F, row.names = F)  

will be divided by being writeable and create a file only three lines How can the format of the output produced by matispilliter be saved in * .txt file?

and when complete (", 1" and above required An example

"tstep" 0 "item" 1 "layer" 0

should result in what the result should look like, then the final output will look like this:

  "tstep" 0 "item" 1 "layer" 0 1 277 553 829 1105 2 278 554 830 1106 3 279 555 831 1107 "tstep" 1 "object" 1 "layer" 0 4 280 556 832 1108 5 281 557 833 110 9 6 282 558 834 1110 "tstep" 2 "items" 1 "layer" 0 7 283 55 9 835 1111 8 284 560 836 1112 9 285 561 837 1113  

etc. "Tstep" is moving with every new set of data.

The goal is if I understand you correctly:

  • > Test & lt; - MetSpillers (B, 3,5) are applicable (test, 3, function (x) {write.table (as.data.frame (x), file = "outfile.txt", sep = "\ t", ("\ N", file = "outfile.txt", append = TRUE, fill = F)})


    No comments:

    Post a Comment