In: Statistics and Probability
R software
Create a list made up of two Vectors, two Data frames and Two Matrices.
i) Name the elements of the list appropriately
ii) Output just the two vectors
iii) Output just the two matrices
#Code of the required program
v1=c(1,2,3,4,5) #creating the first vector
v2=c(6,7,8,9,10) #creating the second vector
name1=c("A","B","C","D")
age1=c(10,12,15,20)
name2=c("E","F","G","H")
age2=c(16,19,21,22)
d1=cbind(name1,age1)
d2=cbind(name2,age2)
dd1=data.frame(d1) #creating the first data frame
dd2=data.frame(d2) #creating the second data frame
m1=matrix(c(1,2,3,4,5,6,7,8,9),nrow=3,byrow=T) #creating the
first matrix of order 3*3
m2=matrix(c(9,8,7,6,5,4,3,2,1,0,7,4),nrow=4,byrow=T)#creating the
second matrix of order 4*3
L1=list(v1,v2) #creating first list containing 2 vectors
L2=list(dd1,dd2) #creating second list containing 2
dataframes
L3=list(m1,m2) #creating third list containing 2 matrices
L=list(L1,L2,L3) # creating list of lists
L[[1]] #printing the 2 vectors, which are the 1st element of the
main list
L[[3]] #printing the 2 matrices, which are the 3rd element of the
main list
#(The image attached with is the required output of the program)