Check if object is a caracas matrix
symbol_is_matrix(x)
An object
if (has_sympy() && sympy_version() >= "1.6") {
x <- vector_sym(4)
symbol_is_matrix(x) ## TRUE
x2 <- as.character(x) ## "Matrix([[v1], [v2], [v3], [v4]])"
symbol_is_matrix(x2) ## TRUE
x3 <- as_character_matrix(x) ## R matrix
symbol_is_matrix(x3) ## FALSE
}
#> length not 1
#> [1] FALSE