Search code examples
rr-markdownflextable

r flextable horizontal line on bottom only


I'm trying to create a simple flextable from a 2x2 matrix where the second column includes horizontal lines on the bottom. The output needs to be a Word document created from a .Rmd file. There is an extra horizontal line at the top of the first row, which I do not want. It seems to work fine in html output.

---
output: 
  word_document
---

```{r setup, message=FALSE, warning=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(flextable)
library(dplyr)

tab <- data.frame(
  x = c('Row1', 'Row2:'),
  y = c(NA, NA)
)

flextable::flextable(tab) %>%
  flextable::border_remove() %>%
  flextable::hline(i = 1:2, j = 2, part = 'body') %>%
  flextable::delete_part(part = 'header') 
```

The output looks like this in Word:

enter image description here

And I want it to look like this (as in HTML):

enter image description here


Solution

  • This was a bug, fixed here, v0.7.3.006: https://github.com/davidgohel/flextable/commit/3e2d9361504090eee187a786067a701de4d0401c