Posts

Showing posts from June, 2020

Matrix in R Programming

Image
Matrix in R Matrices are the R objects in which the elements are arranged in a two-dimensional rectangular layout. They contain elements of the same atomic types. Though we can create a matrix containing only characters or only logical values, they are not of much use. We use matrices containing numeric elements to be used in mathematical calculations. A Matrix is created using the  matrix()  function. Syntax The basic syntax for creating a matrix in R is − matrix(data, nrow, ncol, byrow, dimnames) Following is the description of the parameters used − ·       data  is the input vector which becomes the data elements of the matrix. ·       nrow  is the number of rows to be created. ·       ncol  is the number of columns to be created. ·       byrow  is a logical clue. If TRUE then the input vector elements are arranged by row. ·       dimname  is the names assigned to the rows and columns. Create a matrix in R programming Matrix can be created using the  matr