On Wed, 20 Nov 2013, Alaios <ala...@yahoo.com> writes: > Hi there, > I would like to save tabular (in R just matrices) in a txt file but in a way > that they would be somehow readable. > That means keeping columns aligned and rows so one can read easily for > example the 2,3 element. > > IS there a way to do that in R? > capture.output for example does not produce tables in the way I want to have > those.
Please provide an example that shows what you want to achieve, and why capture.output does not work. A <- rnorm(12) dim(A) <- c(4,3) colnames(A) <- LETTERS[1:3] A # A B C # [1,] 1.3883785 1.7264519 -0.1340838 # [2,] 1.0601385 -0.2378076 0.2078081 # [3,] 0.7278065 -0.1279776 -1.1674676 # [4,] 1.3321629 -1.4082142 0.9145042 capture.output(A) # [1] " A B C" # [2] "[1,] 1.3883785 1.7264519 -0.1340838" # [3] "[2,] 1.0601385 -0.2378076 0.2078081" # [4] "[3,] 0.7278065 -0.1279776 -1.1674676" # [5] "[4,] 1.3321629 -1.4082142 0.9145042" # writeLines(capture.output(A), "matrix.txt") ## or similar > > Regards > Alex > [[alternative HTML version deleted]] Please send plain-text emails. -- Enrico Schumann Lucerne, Switzerland http://enricoschumann.net ______________________________________________ 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.