How to merge two apa tables through papaja?

154 Views Asked by At

I need help. I managed to have r tables in APA style using papaja in r markdown. But I need to merge them into one big table(It is going to be sociodemographics).

Sorry If I am not being clear but my situation is something like in this picture.

It doesn't have to be done through papaja but it looks so simple because I have exact columns but I don't know why r doesn't let me merge them.

1

There are 1 best solutions below

0
crsh On

If you pass a list of consistently structured data.frames, apa_table() will merge them in one of two ways depending on the setting of merge_method. The following does what you are looking for, I believe.

papaja::apa_table(
  list(
    Head = head(cars, 3)
    , Tail = tail(cars, 3)
  )
  , merge_method = "indent"
)

In Markdown format the results looks as follows.

           speed   dist   
---------  ------  -------
Head                      
\ \ \ 1    4.00    2.00   
\ \ \ 2    4.00    10.00  
\ \ \ 3    7.00    4.00   
Tail                      
\ \ \ 48   24.00   93.00  
\ \ \ 49   24.00   120.00 
\ \ \ 50   25.00   85.00  

(\ are non-breaking spaces used to indent the contents of the first column. Note that merge_method = "table_spanner" only works in papaja documents.)