## How to create with an array functions R

We have taken example of creating a three dimensional array of numbers. Matrix are two dimensional like vectors can contains only one data type whenever more than two dimensions we will use arrays function.
Creating and arrays

dim1 <- c("A1", "A2")
>  dim2 <- c("B1", "B2", "B3")
>  dim3 <- c("C1", "C2", "C3", "C4")
> z <- array(1:24, c(2, 3, 4), dimnames=list(dim1, dim2, dim3))
>
> z
, , C1

B1 B2 B3
A1  1  3  5
A2  2  4  6

, , C2

B1 B2 B3
A1  7  9 11
A2  8 10 12

, , C3

B1 B2 B3
A1 13 15 17
A2 14 16 18

, , C4

B1 B2 B3
A1 19 21 23
A2 20 22 24

> patientID <- c(1, 2, 3, 4)
> age <- c(25, 34, 28, 52)
> diabetes <- c("Type1", "Type2", "Type1", "Type1")
> status <- c("Poor", "Improved", "Excellent", "Poor")
> patientdata <- data.frame(patientID, age, diabetes, status)
> patientdata
patientID age diabetes    status
1         1  25    Type1      Poor
2         2  34    Type2  Improved
3         3  28    Type1 Excellent
4         4  52    Type1      Poor
with(mtcars, {
+     summary(mpg, disp, wt)
+     plot(mpg, disp)
+     plot(mpg, wt)
+ })
> with(mtcars, {
+     stats <- summary(mpg)
+     stats
+ })
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
10.40   15.43   19.20   20.09   22.80   33.90
> with(mtcars, {
+     nokeepstats <- summary(mpg)
+     keepstats <<- summary(mpg)
+ })
> nokeepstats