Академический Документы
Профессиональный Документы
Культура Документы
Generating sequences
Ans.
How to create a matrix of 12 integers from 3 to 14 arranged sequentially in 3 rows as-
? Ans.
In above matrix how to provide titles 'Row1', 'Row2', 'Row3' to the rows and 'Col1', 'Col2', 'Col3' and
'Col4' to the columns? Ans.
How to access and display the element in 2 nd row and third column of above matrix? Ans.
How to display all elements of second row? Ans.
How to display all elements of second column? Ans.
Suppose there are two matrices of name 'mm' and 'nn'. How to (i) add (ii) subtract (iii) multiply and
(iv) divide them?
R-Arrays
Ans.
vec1<-c(2,5,6)
vec2<-c(4,6,7)
vec3<-c(3,2,5)
arr<-array(c(vec1,vec2,vec3), dim = c(3,3,2))
arr
Or,
arr<-array(c(2,5,6,4,6,7,3,2,5), dim=c(3,3,2))
How to give names "Row1", "Row2", "Row3", "Col1", "Col2", "Col3" to row names and column
names as well as names "Matrix1" and "Matrix2" to above matrices?
rnam<-c("Row1", "Row2", "Row3")
cnam<-c("Col1", "Col2", "Col3")
matnam<-c("Matrix1","Matrix2")
arr<-array(c(2,5,6,4,6,7,3,2,5), dim=c(3,3,2), dimnames=list(rnam, cnam, matnam))
arr
How to print the element in the first row and third column of the second matrix? Ans.
How to display all elements in the third row of the first matrix? Ans.
How to display all elements in the second column of the first matrix? Ans.
How to display all elements of the second matrix? Ans.
How to extract two matrices in 'arr1' in names 'mm1' and 'mm2'? Ans.
How to display sum of elements row-wise of both matrices? Ans.
How to display sum of elements column-wise of both matrices? Ans.
How to display sum of elements matrix-wise of both matrices? Ans.
How to display mean of elements row-wise of both matrices? Ans.