I like to print a vector, wrapped by rows of 10.
Below the first command below works for 20 numbers.

The second command is ugly. How can I print the 25 numbers into 2 rows 
of ten plus a helf row of 5? Thanks.

 > x<-1:20; matrix(x,nrow=2,byrow=T)
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]    1    2    3    4    5    6    7    8    9    10
[2,]   11   12   13   14   15   16   17   18   19    20
 > x<-1:25; matrix(x,nrow=2,byrow=T)
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
[1,]    1    2    3    4    5    6    7    8    9    10    11 12    13
[2,]   14   15   16   17   18   19   20   21   22    23    24 25     1
Warning message:
In matrix(x, nrow = 2, byrow = T) :
   data length [25] is not a sub-multiple or multiple of the number of 
rows [2]
 >

-- 
s...@hqu.edu.cn


        [[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.

Reply via email to