- 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 a large number of values in R without index?
Whenever we print any vector then the left-hand side of the R window shows indexing, even if we have one value in the vector the index will be there. For example, if we print a vector that has value equal to 2 then the print output will be [1] 2, here [1] represents the index. If we want to print the vector without index then cat function can be used as shown in the below examples.
Example1
x1<−1:50 x1
Output
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
Example
cat(x1,fill=TRUE)
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
Example2
x2<−rnorm(80) x2
Output
[1] −0.80521374 0.31958949 −1.48420309 0.81002518 −0.21996595 −1.00172996 [7] 0.22351739 0.88238127 −0.39634599 −0.03713212 −0.98835229 −1.25814376 [13] 0.87085572 −0.85611684 −0.29874494 −1.24726965 0.58367707 0.59283764 [19] 1.12208675 −0.99539174 −1.00296505 0.14744371 1.07498541 −0.06393804 [25] 1.05421836 0.78820041 −1.83124330 −0.39376746 0.78146314 1.73795705 [31] 0.76103401 −0.99425354 −0.68722593 0.41017802 2.17813236 0.55434245 [37] 0.62527078 −0.56166543 0.06025381 0.81553325 0.38276496 −0.54946978 [43] 2.82117758 −0.39764193 1.13038425 −0.13615824 −0.32063000 −0.22354904 [49] −1.70144034 −0.87538953 0.71908202 −0.68515454 0.68152735 −3.61314448 [55] −0.45074050 −1.19185745 −0.38136640 0.44618919 −2.15542430 −0.46384009 [61] 0.75799481 0.93987283 1.23951174 0.30288382 −1.48214127 −1.93995177 [67] −0.58862690 −0.09822009 1.10421757 0.48513715 −0.55996766 0.72119011 [73] 2.24702108 −0.37606973 0.66518716 1.15377041 1.19221007 0.47804031 [79] 0.33829431 −0.63047169
Example
cat(x2,fill=TRUE)
Output
−0.8052137 0.3195895 −1.484203 0.8100252 −0.219966 −1.00173 0.2235174 0.8823813 −0.396346 −0.03713212 −0.9883523 −1.258144 0.8708557 −0.8561168 −0.2987449 −1.24727 0.5836771 0.5928376 1.122087 −0.9953917 −1.002965 0.1474437 1.074985 −0.06393804 1.054218 0.7882004 −1.831243 −0.3937675 0.7814631 1.737957 0.761034 −0.9942535 −0.6872259 0.410178 2.178132 0.5543425 0.6252708 −0.5616654 0.06025381 0.8155332 0.382765 −0.5494698 2.821178 −0.3976419 1.130384 −0.1361582 −0.32063 −0.223549 −1.70144 −0.8753895 0.719082 −0.6851545 0.6815273 −3.613144 −0.4507405 −1.191857 −0.3813664 0.4461892 −2.155424 −0.4638401 0.7579948 0.9398728 1.239512 0.3028838 −1.482141 −1.939952 −0.5886269 −0.09822009 1.104218 0.4851372 −0.5599677 0.7211901 2.247021 −0.3760697 0.6651872 1.15377 1.19221 0.4780403 0.3382943 −0.6304717
Example3
x3<−rpois(150,5) x3
Output
[1] 1 6 7 7 6 8 5 2 7 2 6 4 5 5 3 6 3 3 7 6 1 8 6 6 6 [26] 2 3 4 4 4 4 5 2 5 8 1 3 3 4 3 1 3 6 6 10 6 2 5 5 2 [51] 7 4 4 9 6 7 2 6 2 5 5 7 4 3 7 6 4 2 6 8 6 7 3 4 8 [76] 2 6 5 4 5 4 5 5 3 5 6 6 8 3 4 4 7 6 4 4 2 5 7 2 10 [101] 3 5 5 6 7 9 2 7 9 5 7 6 0 4 6 7 8 4 5 3 4 3 7 7 5 [126] 13 4 3 9 9 7 6 4 7 8 5 7 4 7 4 9 5 8 4 1 6 6 2 10 7
Example
cat(x3,fill=TRUE)
Output
1 6 7 7 6 8 5 2 7 2 6 4 5 5 3 6 3 3 7 6 1 8 6 6 6 2 3 4 4 4 4 5 2 5 8 1 3 3 4 3 1 3 6 6 10 6 2 5 5 2 7 4 4 9 6 7 2 6 2 5 5 7 4 3 7 6 4 2 6 8 6 7 3 4 8 2 6 5 4 5 4 5 5 3 5 6 6 8 3 4 4 7 6 4 4 2 5 7 2 10 3 5 5 6 7 9 2 7 9 5 7 6 0 4 6 7 8 4 5 3 4 3 7 7 5 13 4 3 9 9 7 6 4 7 8 5 7 4 7 4 9 5 8 4 1 6 6 2 10 7
Example4
x4<−runif(80,2,5) x4
Output
[1] 4.435970 2.624657 2.451233 4.442715 2.190130 2.226768 3.177817 2.178521 [9] 2.234834 2.228027 4.381513 2.052545 2.744667 3.162011 4.731392 4.378479 [17] 4.474160 3.416653 4.903176 3.525459 4.711460 4.337899 3.336221 4.640738 [25] 3.075943 4.630204 4.372429 4.393392 4.678343 2.356057 3.652575 4.311324 [33] 2.333218 3.325070 3.993173 4.402070 3.938035 2.853330 3.731457 2.789883 [41] 4.016687 3.593640 4.553039 2.479682 2.235848 3.975596 4.436557 4.888424 [49] 3.426769 3.536130 3.465132 4.423580 4.008968 2.218030 4.907232 3.751205 [57] 2.782190 4.860979 3.680459 3.953126 4.426685 4.086084 4.101165 4.857805 [65] 2.475631 4.177959 4.936971 3.693090 4.383131 4.638622 4.576787 2.672324 [73] 4.619832 3.576587 4.285013 2.985745 2.228742 3.732050 2.636020 4.450006
Example
cat(x4,fill=TRUE)
Output
4.43597 2.624657 2.451233 4.442715 2.19013 2.226768 3.177817 2.178521 2.234834 2.228027 4.381513 2.052545 2.744667 3.162011 4.731392 4.378479 4.47416 3.416653 4.903176 3.525459 4.71146 4.337899 3.336221 4.640738 3.075943 4.630204 4.372429 4.393392 4.678343 2.356057 3.652575 4.311324 2.333218 3.32507 3.993173 4.40207 3.938035 2.85333 3.731457 2.789883 4.016687 3.59364 4.553039 2.479682 2.235848 3.975596 4.436557 4.888424 3.426769 3.53613 3.465132 4.42358 4.008968 2.21803 4.907232 3.751205 2.78219 4.860979 3.680459 3.953126 4.426685 4.086084 4.101165 4.857805 2.475631 4.177959 4.936971 3.69309 4.383131 4.638622 4.576787 2.672324 4.619832 3.576587 4.285013 2.985745 2.228742 3.73205 2.63602 4.450006
Example5
x5<−rexp(50,2.35) x5
Output
[1] 1.016516217 0.721335837 0.338276694 0.400194614 0.582205216 0.007181041 [7] 0.199392134 0.409682007 0.159855571 0.508902457 1.154262683 0.099887098 [13] 0.103252343 0.906729850 0.050266374 0.057188442 0.519506878 0.402857089 [19] 0.218303973 0.047213354 0.201429579 0.469359258 0.378838251 0.107099142 [25] 0.359931404 0.811271829 0.422585112 0.655336554 0.157745503 0.270419961 [31] 0.273113782 0.044406735 0.987502275 1.803740455 0.810761784 0.230156457 [37] 0.011306944 0.107074123 2.575930173 0.120097098 0.069905263 0.004458232 [43] 0.130728411 0.263245955 0.247016598 0.056639419 0.444263721 0.155409799 [49] 0.136015234 0.727748260
Example
cat(x5,fill=TRUE)
Output
1.016516 0.7213358 0.3382767 0.4001946 0.5822052 0.007181041 0.1993921 0.409682 0.1598556 0.5089025 1.154263 0.0998871 0.1032523 0.9067298 0.05026637 0.05718844 0.5195069 0.4028571 0.218304 0.04721335 0.2014296 0.4693593 0.3788383 0.1070991 0.3599314 0.8112718 0.4225851 0.6553366 0.1577455 0.27042 0.2731138 0.04440673 0.9875023 1.80374 0.8107618 0.2301565 0.01130694 0.1070741 2.57593 0.1200971 0.06990526 0.004458232 0.1307284 0.263246 0.2470166 0.05663942 0.4442637 0.1554098 0.1360152 0.7277483
Advertisements