# How to print the vector elements vertically in R?

By default, the vector elements are printed horizontally in R environment, suppose a vector x has five values then they will be printed as 1, 2, 3, 4, 5. And if we want to print them vertically then the output will be −

1
2
3
4
5

The printing of these values in vertical form can be done by using the below command −

cat(paste(x),sep="")

## Example

Live Demo

x1<-rnorm(20)
x1

## Output

[1]  -0.21762527 -0.41558602  1.31715506  1.29395466 -0.18461247 0.01315274
[7]   0.57771289  0.20604628  1.94438915  0.60161282  0.99330286 2.01009149
[13]  0.92017331 -1.85041327 -1.80692023 -1.82755564  1.11699829 0.64647509
[19] -1.10505253  0.28583539

cat(paste(x1),sep="
")

-0.217625267942574
-0.415586019985825
1.31715505907589
1.29395466104286
-0.184612472150405
0.0131527375687808
0.577712886566497
0.206046280839523
1.94438915282256
0.601612819106714
0.993302860745902
2.01009149024866
0.920173312461327
-1.85041326987246
-1.80692023263947
-1.82755563513533
1.11699829377698
0.64647509397493
-1.10505253347078
0.285835386881493

## Example

Live Demo

x2<-rpois(20,5)
x2

## Output

[1] 6 6 3 6 6 10 4 6 9 9 2 5 7 1 7 5 5 6 2 8

cat(paste(x2),sep="
")

6
6
3
6
6
10
4
6
9
9
2
5
7
1
7
5
5
6
2
8

## Example

Live Demo

x3<-LETTERS[1:26]
x3

## Output

[1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S"
[20] "T" "U" "V" "W" "X" "Y" "Z"

cat(paste(x3),sep="
")

A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z