'How to add table headers in r
I've made this table, but I want to add headers to my table which show the categories I'm comparing. At this point I've got this:
n <- c('like', 'must-be','neutral','live-with','dislike')
t <- table(factor(d$s1q4, levels = 1:5),factor(d$s1q1, levels = 1:5))
colnames(t) <- n
rownames(t) <- n
t
but now I want to add a name for d$s1q4 and d$s1q1 and make it show up in the table.
Solution 1:[1]
We may use names on the dimnames
names(dimnames(t)) <- c("s1q4", "s1q1")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | akrun |
