Dear Steven, The function "write()" has a parameter "columns". And sprint() can do do some formatting in C style.
x <- rnorm(100) s <- sprintf( fmt="%8.2f" ,x ) write(s, file="", ncolumns=7L) Cheers, Lei On Mon, 22 Jul 2019 at 07:37, Steven <s...@hqu.edu.cn> wrote: > > Is there a convenient way to print a vector into rows of a specified > column length? What I need is to print in the old FORTRAN format, viz., > > format(10F8.2) > > which would print, for instance, a vector of 25 into two rows of 10 plus > an incomplete row of 5. I managed to write a procedure for that task, as > shown below (except that I prefer simply blanks rather than the NA). I > am too embarrassed to even show the procedure. In short, I like to print > in the above FORTRAN format. Thank you. > > ---- > > [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 0.66 0.26 0.82 > 0.73 0.13 0.05 0.56 0.67 0.74 0.87 [2,] 0.91 0.25 0.40 0.39 0.50 0.89 > 0.07 0.84 0.14 0.75 [3,] 0.38 0.08 0.86 0.97 0.56 NA NA NA NA NA > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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.