- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# 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

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

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

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

- Related Articles
- How to print string vectors vertically in R?
- How to replace one vector elements with another vector elements in R?
- How to find the frequency vector elements that exists in another vector in R?
- How to print a factor vector without levels in R?
- How to convert the repeated elements of strings in a vector to unique elements in R?
- How to select random elements from an R vector?
- How to find the intersection of elements in a string vector in R?
- How to remove some last elements of a vector in R?
- How to create unordered triplets of a vector elements in R?
- How to remove the first replicate in a vector using another vector that contains similar elements in R?
- How to find the table of ordered frequencies of vector elements in R?
- How to calculate two period moving average for vector elements in R?
- How to divide columns of a matrix by vector elements in R?
- How to create an upper triangular matrix using vector elements in R?
- How to cut the elements of a numeric vector into multiple intervals in R?

Advertisements