1

I've been knitting to a Word Document from an .rmd file using papaja. I have found that when there is a blank cell in a row, that particular row's height is disproportionately taller than rows without. I've set up my .rmd using the provided template from papaja.

This table produces a normal looking table in a word document:

data <- mtcars

table_1 <- data %>%
  group_by(vs) %>%
  summarise("Mean cyl" = mean(cyl), "Mean wt" = mean(wt))

apa_table(table_1, caption = "Table 1 with no blank space")

However, if I remove one of the column headers and replace it with just an empty character string, like this:

table_2 <- table_1

colnames(table_2) <- c("","Mean cyl","Mean wt")

apa_table(table_2, caption = "Table 2 with a blank space")

The row that the blank space is in is much taller than the table without the blank space. I've played around with it and it also happens when I just use kable() to knit a table, so it might have something to do with kable. I'll attach a screenshot of what the two tables look like. Oh, bonus question, is there any way to put "Table X:" and the table caption on the same line? Tables rendered in a word doc

  • Hi Adam, I just tried to reproduce your problem on a Linux system and for me, your code generates two tables with the same heights for the header rows. So I guess this is specific either to the operating system (Are you using Windows or Mac OS?) or the specific version of a package involved in generating the final document. Can you provide some more information about your setup so I can try to reproduce it? – Marius Barth Jul 12 '20 at 09:44
  • Hi there, sorry I didn't see this until just now! I'm using a Mac with OS 10.15.2. I'm using Word Version 16.14.1. I'm using papaja v 0.1.0.999, knitr v 1.29, kableExtra 1.1.0. I think these are the relevant packages, but let me know if you think you need any more info! – Adam Pettitt Jul 24 '20 at 20:11

1 Answers1

0

I can confirm that this happens in Word. However, the this doesn't seem to be caused by apa_table() or papaja. If you create a table in pandoc-syntax by hand, you get the same behavior, both with apa6_docx() and the standard word_document()-output format, albeit less pronounced in the latter because of the tighter line spacing.

Table: Table 2 with a blank space

     Mean cyl    Mean wt
---  ---------  ---------
  0   7.444444   3.688556
  1   4.571429   2.611286

So, this may be unintended behavior in pandoc and you could try opening an issue on GitHub.

As workaround you can use non-breaking space as column header:

colnames(table_2) <- c("\\ ","dsfasdf","Mean wt")

apa_table(table_2, caption = "Table 2 with a blank space")
crsh
  • 1,699
  • 16
  • 33