Aim: Write A R Script To Demonstrate The Use of Matrix Do Some Computations
Aim: Write A R Script To Demonstrate The Use of Matrix Do Some Computations
Aim: Write A R Script To Demonstrate The Use of Matrix Do Some Computations
Aim:
Write a R script to demonstrate the use of matrix do some computations.
Hardware Requirement:
Intel P-IV 2.70 GHz Processor, 1 GB RAM, 256 GB HDD, 15” LCD Monitor, Keyboard,
Mouse.
Software Requirement:
R Tool, R Studio, Ubuntu 14.04 LTS
Theory:
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.
Syntax:
The basic syntax for creating a matrix in R is −
data is the input vector which becomes the data elements of the matrix.
byrow is a logical clue. If TRUE then the input vector elements are arranged by row.
Example:
Create a matrix taking a vector of numbers as input.
SYCET/ CSE/LOM/IDSR
[1] 5
[1] 13
col1 col2 col3
6 7 8
row1 row2 row3 row4
5 8 11 14
Matrix Computations:
Various mathematical operations are performed on the matrices using the R operators. The
result of the operation is also a matrix.
The dimensions (number of rows and columns) should be same for the matrices involved in
the operation.
Result of subtraction
[,1] [,2] [,3]
[1,] -2 -1 -1
[2,] 7 -5 2
Conclusion:
Hence we have studied basic syntactical construct of Java.