0

I want to concatenate my two tables to see them in well aligned.

Here's an exemple [table 1]

ID  Nb    Name
1   2500  Alex
2   3001  Sam

[Table 2]

ID    Nb2     Name
1   1201445  Lea
2   14120    Remy

When I try to knit my table I have this:

ID  Nb2    Name
1   2500  Alex
2   3001  Sam
ID    Nb       Name
1     1201445  Lea
2     14120    Remy

But I want to have this:

ID     Nb         Name
1     2500        Alex
2     3001        Sam
ID     Nb2         Name
1     1201445     Lea
2     14120       Remy
user438383
  • 5,716
  • 8
  • 28
  • 43
Ali Anis
  • 63
  • 6
  • What's the code you're using? If you're using something like `concat(table2, table1)` change the order of the arguments? – Phil Jul 26 '21 at 12:27
  • I just read csv file as data frame and use ` regulartable(mydataframe) %>% theme_zebra() %>% autofit()` – Ali Anis Jul 26 '21 at 12:29
  • no one can help to resolve this probleme ? – Ali Anis Jul 26 '21 at 18:02
  • I don't see how you're concatenating two tables with the code you've supplied. Can you include some data and code https://stackoverflow.com/q/5963269/3022126 – Phil Jul 27 '21 at 21:02

1 Answers1

1

Analyzing the code you provided (I have added packages that are needed):

require(dplyr)
require(flextable)

regulartable(mydataframe) %>% theme_zebra() %>% autofit()

I can see that you are using autofit() function, which sets the height and width of the columns automatically to fit best to data in the dataframe, and as I understand - you do it separately for each table. To solve this formatting issue, you don't need to concatenate those dataframes, but rather you could set the same width of columns for each table, which would look like this:

regulartable(mydataframe) %>% theme_zebra() %>% width(width = 1)

Depending on what kind of report you are creating, you should consider what type of data will be displayed in your tables and adjust the width parameter in the width function. It is worth mentioning that the width parameter takes a number representing the number of inches that your column should be.

I strongly recommend you reading documentation of flextable package to get further information on formatting those tables of yours.