Heres how to make matrices via a similar pattern but for iris, rather than trees.

```
# Consider "iris" dataset in base R.
#clean the dataset by removing the rows having largest and next largest Petal Lengths
# AND removing the rows having smallest and next smallest Petal Lengths
library(tidyverse)
#how many records to start with ?
nrow(iris)
#150
which.min(iris$Petal.Length)
#23
which.max(iris$Petal.Length)
#119
iris_p1 <- slice(iris,
-23,
-115)
which.min(iris_p1$Petal.Length)
#14
which.max(iris_p1$Petal.Length)
#117
iris_p2<- slice(iris_p1,
-14,
-114)
#how many records of cleaned data ?
nrow(iris_p2)
#146
#From the cleaned data consider the columns Petal.Length, Sepal length (in that order) as matrix A
#and insert a vector having 1s as the first column of this matrix A,
#i.e. all the values of the first column should have 1.
(matrix_A <- cbind(1,select(iris_p2,
Petal.Length,Sepal.Length) %>% as.matrix()))
#Create matrix b with column 'Petal width' from cleaned data.
(matrix_B <- select(iris_p2,Petal.Width) %>% as.matrix())
```

I wonder about whether you made errors reporting the required matrix operations ? were you given text which you are duplicating exactly, or have you transcribed that from an image ?