Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
How to create a matrix with only one row in R?
To create a matrix with only one row in R, we can set the nrow argument of matrix function to 1.
For example, if we want to create a matrix say M with only one row then it can be done by using the command given below −
MCheck out the below examples to understand the output of one row matrix.
Example 1
To create a matrix with only one row in R, use the code given below −
M1The following matrix is created −
[,1] [,2] [,3] [,4] [,5] [1,] 0 2 1 1 1Example 2
To create a matrix with only one row in R, use the code given below −
M2The following matrix is created −
[,1] [,2] [,3] [,4] [,5] [1,] 2 4 6 8 2Example 3
To create a matrix with only one row in R, use the code given below −
M3The following matrix is created −
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 8 7 3 2 5 5 6 6 4 3Example 4
To create a matrix with only one row in R, use the code given below −
M4The following matrix is created −
[,1] [,2] [1,] 2 3Example 5
To create a matrix with only one row in R, use the code given below −
M5The following matrix is created −
[,1] [,2] [1,] 37 38Example 6
To create a matrix with only one row in R, use the code given below −
M6The following matrix is created −
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 62 49 46 53 49 58 50 48 49 53Example 7
To create a matrix with only one row in R, use the code given below −
M7The following matrix is created −
[,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.9545686 0.5495047 1.403797 -0.1845401 0.5164328 -0.9767084Example 8
To create a matrix with only one row in R, use the code given below −
M8The following matrix is created −
[,1] [,2] [,3] [,4] [,5] [,6] [1,] 10.35974 7.565574 9.575034 13.29151 6.77356 9.180579Example 9
To create a matrix with only one row in R, use the code given below −
M9The following matrix is created −
[,1] [,2] [,3] [1,] 4.652802 2.331193 9.452688Example 10
To create a matrix with only one row in R, use the code given below −
M10The following matrix is created −
[,1] [,2] [,3] [,4] [1,] 0.9369164 4.111468 1.368531 1.036329Example 11
To create a matrix with only one row in R, use the code given below −
M11The following matrix is created −
[,1] [,2] [,3] [,4] [,5] [1,] 0.25 2.8 -0.49 -0.68 -0.1Example 12
To create a matrix with only one row in R, use the code given below −
M12The following matrix is created −
[,1] [,2] [,3] [1,] 4.75 6.62 6.56
