When I call matrices from a function, they are called but are not
recognized as matrices. I use the code below. From the main function, when
I use the command is.matrix(), the response is FALSE. Why are the matrices
not recognized as matrices? Thanks in advance for any guidance.

#This function creates matrices and returns them in a list.

my_func <- function() {

  matrix_1 = matrix(c(1,2,3,4), ncol = 2, nrow = 2)

  matrix_2 = matrix(c(5,6,7,8), ncol = 2, nrow = 2)

  my_list <- list(matrix_1,matrix_2)

  return(my_list)

}

#This function calls the myfunc function.

main_func <- function() {

  result <- myfunc()

  result_1 <- (result[1])

  print(result_1)

  print(is.matrix(a))

  result_2 <- (result[2])

  print(result_2)

  print(is.matrix(result_2))

}

main_func()

> #This function creates matrices and returns them in a list.

> my_func <- function() {

+   matrix_1 = matrix(c(1,2,3,4), ncol = 2, nrow = 2)

+   matrix_2 = matrix(c(5,6,7,8), ncol = 2, nrow = 2)

+   my_list <- list(matrix_1,matrix_2)

+   return(my_list)

+ }

> #This function calls the myfunc function.

> main_func <- function() {

+   result <- myfunc()

+   result_1 <- (result[1])

+   print(result_1)

+   print(is.matrix(a))

+   result_2 <- (result[2])

+   print(result_2)

+   print(is.matrix(result_2))

+ }

> main_func()

[[1]]

     [,1] [,2]

[1,]    1    3

[2,]    2    4



[1] FALSE

[[1]]

     [,1] [,2]

[1,]    5    7

[2,]    6    8



[1] FALSE

	[[alternative HTML version deleted]]

