R version 4.2.1 (2022-06-23 ucrt) -- "Funny-Looking Kid" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. [Previously saved workspace restored] > v1<-c(1:12) > M1 <- matrix(v1,nrow=3,ncol=4,byrow=TRUE) > > v2<-c(13:24) > M2 <- matrix(v2,nrow=3,ncol=4,byrow=TRUE) > > names<- c("Kim", "Kayne", "North") > info<-c("Height", "Weight", "Shoe Size","Hair Length") > > A<- array(c(M1,M2),dim=c(3,4,2),dimnames=list(names,info)) > > A[,,1] Height Weight Shoe Size Hair Length Kim 1 2 3 4 Kayne 5 6 7 8 North 9 10 11 12 > A[,,2] Height Weight Shoe Size Hair Length Kim 13 14 15 16 Kayne 17 18 19 20 North 21 22 23 24 > > ##Question > v3=c(50,60,70,80,45,35,70,50,23,29,30,45,30,35,40,45) > M3 <- matrix(v3,nrow=4,ncol=4,byrow=FALSE) > M3 [,1] [,2] [,3] [,4] [1,] 50 45 23 30 [2,] 60 35 29 35 [3,] 70 70 30 40 [4,] 80 50 45 45 > Sub <- c("Phy","Chem","Maths","Bio") > Student<- c("A","B","C","D") > B<- array(M3,dim=c(4,4),dimnames=list(Sub,Student)) > B A B C D Phy 50 45 23 30 Chem 60 35 29 35 Maths 70 70 30 40 Bio 80 50 45 45 > > ##q2 Total marks by A in all subjects > M3[,1] [1] 50 60 70 80 > allsubA=sum(M3[,1]) > allsubA [1] 260 > > ##q3 highest in bio > M3[4,] [1] 80 50 45 45 > high=max(M3[4,]) > high [1] 80 > > ##q4 total marks by B and C > stuB=sum(M3[,2]) > stuC=sum(M3[,3]) > total= stuB +stuC > total [1] 327 > total=sum(M3[,2],M3[,3]) > total [1] 327 > > ##q5 top in chem > top=max(M3[2,]) > top [1] 60 > > > ##q6 min by C > low=min(M3[,3]) > LOW Error: object 'LOW' not found > > low [1] 23 > low=min(M3[,4]) > low [1] 30 > > > #q1 > total=sum(M3[2,],M3[4,]) > total [1] 379 >