They do not get converted, they were characters from the beginning, if you convert your columns into numeric before calling as.matrix() then the matrix is numeric.
library(dplyr)
sample_df <- data.frame(
stringsAsFactors = FALSE,
check.names = FALSE,
row.names = c("M.bro", "Or.tip", "Paint.l", "Pea", "Red.ad", "Ring"),
`1996` = c(" 88", " 90", " 50", " 48", " 6", "190"),
`1997` = c(" 47", " 14", " 0", "110", " 3", " 80"),
`1998` = c("13", "36", " 0", "85", " 8", "96"),
`1999` = c(" 33", " 24", " 0", " 54", " 10", "179"),
`2000` = c(" 86", " 47", " 4", " 65", " 15", "145")
)
sample_df %>%
mutate(across(.fns = as.numeric)) %>%
as.matrix()
#> 1996 1997 1998 1999 2000
#> M.bro 88 47 13 33 86
#> Or.tip 90 14 36 24 47
#> Paint.l 50 0 0 0 4
#> Pea 48 110 85 54 65
#> Red.ad 6 3 8 10 15
#> Ring 190 80 96 179 145
Created on 2022-05-15 by the reprex package (v2.0.1)
BTW, is not necessary to transform a dataset into a matrix in order to plot a barplot, for example
library(tidyverse)
sample_df <- data.frame(
stringsAsFactors = FALSE,
check.names = FALSE,
row.names = c("M.bro", "Or.tip", "Paint.l", "Pea", "Red.ad", "Ring"),
`1996` = c(" 88", " 90", " 50", " 48", " 6", "190"),
`1997` = c(" 47", " 14", " 0", "110", " 3", " 80"),
`1998` = c("13", "36", " 0", "85", " 8", "96"),
`1999` = c(" 33", " 24", " 0", " 54", " 10", "179"),
`2000` = c(" 86", " 47", " 4", " 65", " 15", "145")
)
sample_df %>%
mutate(across(.fns = as.numeric)) %>%
rownames_to_column() %>%
pivot_longer(cols = -rowname, names_to = 'Year', values_to = 'Value') %>%
ggplot(aes(x = Year, y = Value, fill = rowname)) +
geom_col()

Created on 2022-05-15 by the reprex package (v2.0.1)