For some reason my head can't quite grok this named list with attributes.
I am trying to work up a tutorial on using openxlsx and I want to show how to hook a named table using the getTables function. The resulting character vector seems to have the table names as the character elements and the cell references as attributes. How would I say to R "give me the cell references for the table named 'Table1' in the following example:
library(openxlsx)
wb <- loadWorkbook("http://cerebralmastication.github.io/excel_table_data.xlsx")
gt <- getTables(wb, 'input_data')
gt
#> J10:N22 B10:F160
#> "Table1" "example_table"
#> attr(,"refs")
#> [1] "J10:N22" "B10:F160"
str(gt)
#> Named chr [1:2] "Table1" "example_table"
#> - attr(*, "names")= chr [1:2] "J10:N22" "B10:F160"
#> - attr(*, "refs")= chr [1:2] "J10:N22" "B10:F160"
The monstrosity that I cooked up to do this is:
attributes(gt[match(gt, 'Table1')])$names
but the idea of explaining that to a new learner makes me want to cry on their behalf.