Slip 23 - E) Write a script in R to create two vectors of different lengths and give these vectors as input to the array and print second row of second matrix of the array.

Solution:

a=c(1,2,3,4,5)
b=c(2,4,5,7,8,6)
print(a)
print(b)
result=array(c(a,b),dim=c(3,3,2))
print("New Array")
print(result)
print("The second row of the second matrix of the array")
print(result[2,,2])
print("The third row of the third matrix of the array")
print(result[3,3,1])

Post a Comment

0 Comments