Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

We may use names on the dimnames

names(dimnames(t)) <- c("s1q4", "s1q1")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading