With your data assigned to df, you can do the following to get to your desired structure:
library(tidyverse)
df %>% ungroup() %>%
pivot_wider(values_from = n, names_from = matt_ne) %>%
column_to_rownames("health_pa")
Created on 2025-01-30 with reprex v2.1.1