fix column widths in table in r

904 views Asked by At

I'm trying to position a dynamic table plot (no. of columns stay the same, but the contents of those columns might change) such that the position of the column headers are fixed on the x-axis.

My problem is, that the the "width" of the columns (both colnames and contents) might change. What I'm trying to do is build a table where I can specify "the column name of the i-th column is at coordinates (x_i,y_i)". Ideally it would be a table built with ggtexttable

Edit: I think what I'm actually trying to do is have a table where the column widths are fixed (and can be set by me), no matter what data is actually displayed.

Does anyone have an Idea on how to achieve that?

Edit: what I've tried so far:

  • add columns with whitespace in between to "set the positions of the columns". This does not work well however, because not all characters have the same width, so I can't compensate for example a Column name that is shorter by two characters with two more whitespaces in the empty columns.
1

There are 1 answers

0
Tschösi On BEST ANSWER

So I found flexttable, should do what I need:

https://davidgohel.github.io/flextable/reference/width.html