R Programming: Combine the three vectors to become a 3×3 matrix where each column represents a vector
R Programming: Basic Exercise-12 with Solution
Write a R program to create three vectors a,b,c with 3 integers. Combine the three vectors to become a 3×3 matrix where each column represents a vector. Print the content of the matrix.
Sample Solution :
R Programming Code :
a<-c(1,2,3) b<-c(4,5,6) c<-c(7,8,9) m<-cbind(a,b,c) print("Content of the said matrix:") print(m)
 "Content of the said matrix:" a b c [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9
R Programming Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a R program to get the unique elements of a given string and unique numbers of vector.
Next: Write a R program to create a list of random numbers in normal distribution and count occurrences of each value.
Test your Python skills with w3resource's quiz
What is the difficulty level of this exercise?
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework