[R] Printing vectrix
Steven Yen
@yen @end|ng |rom hqu@edu@cn
Mon Mar 25 02:30:07 CET 2019
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]
>
--
syen using hqu.edu.cn
[[alternative HTML version deleted]]
More information about the R-help
mailing list