Flat 10% & upto 50% off + Free additional Courses. Hurry up!
×
UPTO
50%
OFF!

# Matrices

Matrices are the R objects wherein the elements are organized in a 2-D rectangular shape. In a matrix it contains elements of same atomic types.

Matrix function is denoted as matrix().

Syntax

matrix(data, nrow, ncol, byrow, dimnames)

data is the parameter of input, nrow is number of rows and ncol is number of columns to be created; byrow has TRUE or FALSE as its logical values, and dimname is the rows or columns name.

Accessing Elements of a matrix

Any row or column element can be accessed by using column and row index.

Example:

#Defining the column and row names

rn = c(“r1”, “r2”, “r3″, r4”)

cn = c(“c1”, “c2”, “c3”)

#Creating the matrix

A <- matrix(c(1:12), nrow = 4, byrow = TRUE, dimnames= list(rn, cn))

#Accessing 2nd row, 3rd column element

print(A[2,3])

#Accessing  elements of 4th column

print(A[ ,4])

Output:

[1] 6

row1  row2  row3  row4

3        6          9        12

Matrix Computations

Different types of mathematical operations such as matrix addition, subtraction, multiplication and division can be performed on the matrices using R operators.

### "0 Responses on Matrices"

Training in Cities: Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.

## Sales Offer

• To avail this offer, enroll before 29th March 2017.
• This offer cannot be combined with any other offer.
• This offer is valid on selected courses only.
• Please use coupon codes mentioned below to avail the offer