Возможно, достаточно следующего:
df <- as_tibble(Titanic) %>% dplyr::mutate(y_n = if_else(Survived == "Yes", 1, 0))
m <- glm(y_n ~ Class + n + Age + Sex, data = df)
(trm <- attr(m$terms, "term.labels")) # Getting original variables
# [1] "Class" "n" "Age" "Sex"
(asgn <- attr(model.matrix(m$formula, data = df), "assign")) # See ?model.matrix
# [1] 0 1 1 1 2 3 4
cbind(Term = trm[asgn[-1]],
Category = str_replace(names(coef(m)[-1]), trm[asgn[-1]], ""))
# Term Category
# [1,] "Class" "2nd"
# [2,] "Class" "3rd"
# [3,] "Class" "Crew"
# [4,] "n" ""
# [5,] "Age" "Child"
# [6,] "Sex" "Male"
Строка перехвата отсутствует, но при необходимости вы можете добавить ее в случаях, когда asgn[1] == 0
.