R version 4.3.
3 (2024-02-29) -- "Angel Food Cake"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (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.
[R.app GUI 1.80 (8340) aarch64-apple-darwin20]
[Workspace restored from /Users/samriddhisethi/.RData]
[History restored from /Users/samriddhisethi/.Rapp.history]
> vector1<-c(5,9,3)
> vector2<-c(10,11,12,13,14,15)
> result<-array(c(vector1,vector2),dim=c(3,3,2))
> print(result)
, , 1
[,1] [,2] [,3]
[1,] 5 10 13
[2,] 9 11 14
[3,] 3 12 15
, , 2
[,1] [,2] [,3]
[1,] 5 10 13
[2,] 9 11 14
[3,] 3 12 15
> column.names<-c("COL1","COL2","COL3")
> row.names<-("ROW1","ROW2","ROW3")
Error: unexpected ',' in "row.names<-("ROW1","
> row.names("ROW1","ROW2","ROW3")
Error in row.names("ROW1", "ROW2", "ROW3") :
unused arguments ("ROW2", "ROW3")
> row.names<-("ROW1","ROW2","ROW3")
Error: unexpected ',' in "row.names<-("ROW1","
> row.names<-("ROW1","ROW2","ROW3")
Error: unexpected ',' in "row.names<-("ROW1","
> row.names<-("ROW1""ROW2""ROW3")
Error: unexpected string constant in "row.names<-("ROW1""ROW2""
> row.names<-("ROW1" , "ROW2" , "ROW3")
Error: unexpected ',' in "row.names<-("ROW1" ,"
> row.names<-c("ROW1","ROW2","ROW3")
> matrix.names<-c("Matrix1","Matrix2")
> result<-array(c(vector1,vector2),dim=c(3,3,2),dimnames=list(row.names,column.names,matrix.names))
> print(result)
, , Matrix1
COL1 COL2 COL3
ROW1 5 10 13
ROW2 9 11 14
ROW3 3 12 15
, , Matrix2
COL1 COL2 COL3
ROW1 5 10 13
ROW2 9 11 14
ROW3 3 12 15
> print(result[3,2])
Error in result[3, 2] : incorrect number of dimensions
> print(result[3,,2])
COL1 COL2 COL3
3 12 15
> print(result[1,3,1])
[1] 13
> print(result[,,2])
COL1 COL2 COL3
ROW1 5 10 13
ROW2 9 11 14
ROW3 3 12 15
> vector3<-c(9,1,0)
> vector4<-c(6,0,11,3,14,1,2,6,9)
> array2<-array(c(vector3,vector4),dim=c(3,3,2))
> matrix1<-array1[,,2]
Error: object 'array1' not found
> matrix1<-result[,,2]
> matrix2<-array2[,,2]
> result1<-matrix1+matrix2
> print(result)
, , Matrix1
COL1 COL2 COL3
ROW1 5 10 13
ROW2 9 11 14
ROW3 3 12 15
, , Matrix2
COL1 COL2 COL3
ROW1 5 10 13
ROW2 9 11 14
ROW3 3 12 15
> result3<-apply(result,c(1),sum)
> print(result3)
ROW1 ROW2 ROW3
56 68 60
>