Tripartio
Tripartio

Reputation: 2199

How to get flextable::vline to create single border

I want to display a single vertical border using the flextable package in R, but either I can't get it to work or there's a bug in the package (version 0.4.4):

library(flextable)
library(officer) # needed to define border properties

std_border = officer::fp_border(color="orange", width = 1)

# dataset to be used for examples
dat <- head(iris[c(1:5, 51:55, 101:105),])
ft <- regulartable(dat)
border_remove(x = ft)

# add internal borders
hline(ft, i = 3, border = std_border)
vline(ft, j = 3, border = std_border)

The result is this:

flextable results, not as intended

As intended, there is a horizontal line at the bottom of the third data row (starting with Sepal.Length = 4.700); so, hline seems to work as intended. However, I'm having trouble with vline: although there is a vertical line at the right edge of the Petal.Length column, there is also an undesired vertical line at the left edge of that column which I can't get rid of. I only want a single vertical line at the right edge of the specified column 3, which is what I understand to be the documented behaviour for vline.

Is this a bug in flextable 0.4.4 or could someone please help me figure out what I'm doing wrong?

Upvotes: 1

Views: 1944

Answers (1)

David Gohel
David Gohel

Reputation: 10695

This is an issue and has been solved in flextable 0.4.5.

Upvotes: 2

Related Questions