1

I'm trying to create a table in R Markdown/Kable where rows 2, 5, 8, 11, 14 have the same name ("Tattooed") and 3, 6, 9, 12, 15 have the same name ("Prominently Tattooed"). Is there any way to do this?

As you can see in the screenshot, I am currently using a workaround with brackets. But I would like to get rid of them.

Table

Renaming in the data frame doesn't work because the names are duplicated.

table_anova_posthoc <- data.frame(
  matrix(
    nrow = 18, ncol = 8)
  )

rownames(table_anova_posthoc) <- c("Trust", "Tattooed", "Prominently Tattooed", "Responsibility", "Tattooed", "Prominently Tattooed", "Negative Emotionality", "Tattooed", "Prominently Tattooed", "Depression", "Tattooed", "Prominently Tattooed", "Emotional Volatility", "Tattooed", "Prominently Tattooed", "Self-Esteem", "Tattooed", "Prominently Tattooed")

Error when knitting:

Quitting from lines 1593-1799 [unnamed-chunk-5] (Master-Thesis.Rmd)
Error in `.rowNamesDF<-`:
! duplicate 'row.names' are not allowed
Backtrace:
 1. base::`rownames<-`(`*tmp*`, value = `<chr>`)
 3. base::`row.names<-.data.frame`(`*tmp*`, value = value)
 4. base::`.rowNamesDF<-`(x, value = value)
Execution halted

My workaround with brackets:

rownames(table_anova_posthoc) <- c("Trust", "Tattooed (T)", "Prominently Tattooed (T)", "Responsibility", "Tattooed (R)", "Prominently Tattooed (R)", "Negative Emotionality", "Tattooed (NE)", "Prominently Tattooed (NE)", "Depression", "Tattooed (D)", "Prominently Tattooed (D)", "Emotional Volatility", "Tattooed (EV)", "Prominently Tattooed (EV)", "Self-Esteem", "Tattooed (SE)", "Prominently Tattooed (SE)")
lutzberlin
  • 11
  • 2
  • 2
    Welcome! Could you edit your question to include data/code make this reproducible? That will help us help us help you more accurately. Some tips on how to do that are here: [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – jpsmith Aug 28 '23 at 12:42
  • 1
    Done! Hope it's clear!?! – lutzberlin Aug 29 '23 at 08:28

0 Answers0