a11ytables icon indicating copy to clipboard operation
a11ytables copied to clipboard

Add functionality for multi-table sheets

Open matt-dray opened this issue 4 years ago • 3 comments

Consider a sheet with two tables. They should each have their own subtable title and be separated by one empty column.

Note that the guidance suggests you don't have more than one table per sheet, so this is low priority. not a dealbreaker: users will likely be able to create separate sheets, e.g. 'Table 1a' and 'Table 1b', in these instances.

matt-dray avatar Aug 19 '21 12:08 matt-dray

I think the best way to do this—in the current form of {a11ytables}—is to provide a list of dataframes to the tables argument of create_a11ytable().

create_a11ytable(
  tab_titles c("cover", "contents", "notes", "tables", "tables"),
  sheet_types = c("cover", "contents", "notes", "tables", "tables"),
  sheet_titles c("Publication", "Contents", "Notes", "Table 1", "Table 2"),
  tables = list(table_1_df, list(table_2a_df, table_2b_df)
)

It's not that simple though, since each of these tables will also need a subtable title. Would it be awkward to add another (optional) argument to create_a11ytable(), like subtable_titles? Probably, since it likely requires list(list(list())).

create_a11ytable(
  tab_titles c("cover", "contents", "notes", "tables", "tables"),
  sheet_types = c("cover", "contents", "notes", "tables", "tables"),
  sheet_titles c("Publication", "Contents", "Notes", "Table 1", "Table 2"),
  tables = list(
    table_1_df, 
    list(
      list(
        "Table 2a: This is the first subtable",
        table_2a_df
      ),
      list(
        "Table 2b: This is the second subtable",
        table_2b_df
      )
    )
  )
)

This is inelegant obviously. The tables argument was intended to be a method for providing only table-like objects. But how else could this be dealt with? An {a11ytables2} approach that embraces lists from the get-go may be preferable.

matt-dray avatar Dec 27 '23 20:12 matt-dray

Remember the best practice guidance for multiple tables in a sheet, including:

  • the worksheet title should be e.g. 'Worksheet 1: Title' and the subtable titles in the form e.g. 'Table 1a: Title' and 'Table 1b: Title'
  • The note on the number of tables should expand to: ‘This worksheet contains [e.g. eight] tables presented next to each other horizontally with one blank column in between each table. Each table applies to [e.g. a different age group].’

matt-dray avatar Dec 27 '23 20:12 matt-dray

Hello, I was introduced to you package through GAF newsletter, It's great. I am in the process of updating the RAP using it. The product I produce for publication has 2 tables on one of the tabs (a table 5a and 5b) has this functionality been developed? If so could you share some exemplar code. Thanks

Kath1240 avatar Mar 06 '25 15:03 Kath1240