-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class hierarchy document #637
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3cebce5
first pass document.
ayogasekaram 2b45f3c
additional setup
ayogasekaram da631d5
updating with changes in main
ayogasekaram 6fa5cfc
Move file to inst/dev-guide
edelarua c4e24ae
Update output format, render location
edelarua e86831e
Merge branch 'main' into 571_class_hierarchy_devguide@main
Melkiades a758549
Merge branch 'main' into 571_class_hierarchy_devguide@main
edelarua 4cce214
Update article location, disclaimer
edelarua cf8fad8
Align article formatting, add missing links to other dev guide articles
edelarua c5f84dd
Fix
edelarua 9580deb
merge changes from main
ayogasekaram 42e0746
Merge branch 'main' into 571_class_hierarchy_devguide@main
edelarua 5df4851
Fix other article titles
edelarua bb49aca
Merge branch 'main' into 571_class_hierarchy_devguide@main
shajoezhu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
title: "Table Hierarchy" | ||
author: "Abinaya Yogasekaram" | ||
date: "`r Sys.Date()`" | ||
output: html_document | ||
editor_options: | ||
chunk_output_type: console | ||
--- | ||
|
||
```{r setup, include=FALSE} | ||
knitr::opts_chunk$set(echo = TRUE) | ||
``` | ||
|
||
## Disclaimer | ||
|
||
This article is intended for use by developers only and will contain low-level explanations of the topics covered. For user-friendly vignettes, please see the [Articles](https://insightsengineering.github.io/rtables/main/articles/index.html) page on the `rtables` website. | ||
|
||
Any code or prose which appears in the version of this article on the `main` branch of the repository may reflect a specific state of things that can be more or less recent. This guide describes very important aspects of table hierarchy that are unlikely to change. Regardless, we invite the reader to keep in mind that the current repository code may have drifted from the following material in this document, and it is always the best practice to read the code directly on `main`. | ||
|
||
Please keep in mind that `rtables` is still under active development, and it has seen the efforts of multiple contributors across different years. Therefore, there may be legacy mechanisms and ongoing transformations that could look different in the future. | ||
|
||
## Introduction | ||
|
||
The scope of this vignette is to understand the structure of rtable objects, class hierarchy with an exploration of tree structures as S4 objects. Exploring table structure enables a better understanding of rtables concepts such as split machinery, tabulation, pagination and export. More details from the user's perspective of table structure can be found in the relevant vignettes. | ||
|
||
isS4 | ||
getclass - for class structure | ||
|
||
|
||
## Process and Methods | ||
|
||
We invite developers to use the provided examples to interactively explore the rtables hierarchy. The most helpful command is 'getClass' for a list of the slots associated with a class, in addition to related classes and their relative distances. | ||
|
||
## Representation of Information before generation | ||
|
||
|
||
## Table Representation | ||
"PredataAxisLayout" class is used to define the data subset instructions for tabulation. 2 subclasses (one for each axis): PredataColLayout, PredataRowLayout | ||
|
||
## Slots, Parent-Child Relationships | ||
|
||
## Content (summary row groups) | ||
|
||
Splits are core functionality for rtables as tabulation and calculations are often required on subsets of the data. | ||
|
||
## Split Machinery | ||
```{r, message=FALSE} | ||
library(rtables) | ||
getClass("TreePos") | ||
``` | ||
|
||
"TreePos" class contains split information as a list of the splits, split label values, and the subsets of the data that are generated by the split. | ||
|
||
AllSplit | ||
RootSplit | ||
MultiVarSplit | ||
VarStaticCutSplit | ||
CumulativeCutSplit | ||
VarDynCutSplit | ||
CompoundSplit | ||
VarLevWBaselineSplit | ||
|
||
|
||
The highest level of the table hierarchy belong to "TableTree". The code below identifies the slots associated with with this class. | ||
```{r} | ||
getClass("TableTree") | ||
``` | ||
|
||
As an S4 object, the slots can be accessed using "@" (similar to the use of "$" for list objects). | ||
You'll notice there are classes that fall under "Extends". The classes contained here have a relationship to the TableTree object and are "virtual" classes. To avoid the repetition of slots and carrying the same data (set of slots for example) that multiple classes may need, rtables extensively uses virtual classes. A virtual class cannot be instantiated, the purpose is for other classes to inherit information from it. | ||
|
||
|
||
```{r} | ||
|
||
lyt <- basic_table(title = "big title") %>% | ||
split_rows_by("SEX", page_by = TRUE) %>% | ||
analyze("AGE") | ||
|
||
tt <- build_table(lyt, DM) | ||
|
||
# Though we don't recommend using str for studying rtable objects, | ||
# we do find it useful in this instance to visualize the parent/child relationships. | ||
str(tt, max.level=2) | ||
``` | ||
|
||
## Tree Paths | ||
|
||
Root to Leaves, are vectors of vectors | ||
Tables are tree, nodes in the tree can have summaries associated with them. Tables are trees because of the nested structure. There is also the benefit of keeping and repeating necessary information when trying to paginate a table. | ||
|
||
Children of ElementaryTables are row objects. TableTree can have children that are either row objects or other table objects. | ||
|
||
|
||
#### TODO: | ||
Create Tree Diagram showing class hierarchy. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,7 @@ | |
title: "Tabulation" | ||
author: "Davide Garolini" | ||
date: '`r Sys.Date()`' | ||
output: | ||
html_document: | ||
theme: spacelab | ||
toc: true | ||
toc_float: | ||
collapsed: false | ||
output: html_document | ||
editor_options: | ||
chunk_output_type: console | ||
--- | ||
|
@@ -28,7 +23,7 @@ Being that this a working document that may be subjected to both deprecation and | |
|
||
## Introduction | ||
|
||
Tabulation in `rtables` is a process that takes a pre-defined layout and applies it to data. The layout object, with all of its splits (see xxx link split machinery article) and `analyze`s, can be applied to different data to produce valid tables. This process happens principally within the `tt_dotabulation.R` file and the user-facing function `build_table` that resides in it. We will occasionally use functions and methods that are present in other files, like `colby_construction.R` or `make_subset_expr.R`. We assume the reader is already familiar with the documentation for `build_table`. We suggest reading the split machinery vignette (xxx link) prior to this one, as it is instrumental in understanding how the layout object, which is essentially built out of splits, is tabulated when data is supplied. | ||
Tabulation in `rtables` is a process that takes a pre-defined layout and applies it to data. The layout object, with all of its splits and `analyze`s, can be applied to different data to produce valid tables. This process happens principally within the `tt_dotabulation.R` file and the user-facing function `build_table` that resides in it. We will occasionally use functions and methods that are present in other files, like `colby_construction.R` or `make_subset_expr.R`. We assume the reader is already familiar with the documentation for `build_table`. We suggest reading the [Split Machinery article](https://insightsengineering.github.io/rtables/main/articles/dev-guide/dg_split_machinery.html) prior to this one, as it is instrumental in understanding how the layout object, which is essentially built out of splits, is tabulated when data is supplied. | ||
|
||
## Tabulation | ||
|
||
|
@@ -70,7 +65,7 @@ [email protected] # might not preserve the names # it works only when it is another clas | |
# We suggest doing extensive testing about these behaviors in order to do choose the appropriate one | ||
``` | ||
|
||
Along with the various checks and defensive programming, we find `PreDataAxisLayout` which is a virtual class that both row and column layouts inherit from. Virtual classes are handy for group classes that need to share things like labels or functions that need to be applicable to their relative classes. See more information about the `rtables` class hierarchy in the dedicated article here (xxx add). | ||
Along with the various checks and defensive programming, we find `PreDataAxisLayout` which is a virtual class that both row and column layouts inherit from. Virtual classes are handy for group classes that need to share things like labels or functions that need to be applicable to their relative classes. See more information about the `rtables` class hierarchy in the dedicated article [here](https://insightsengineering.github.io/rtables/main/articles/dev-guide/dg_table_hierarchy.html). | ||
|
||
Now, we continue with `build_table`. After the checks, we notice `TreePos()` which is a constructor for an object that retains a representation of the tree position along with split values and labels. This is mainly used by `create_colinfo`, which we enter now with `debugonce(create_colinfo)`. This function creates the object that represents the column splits and everything else that may be related to the columns. In particular, the column counts are calculated in this function. The parameter inputs are as follows: | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ayogasekaram Is this the only missing thing? I think we can eventually reiterate updates in the future, what do you think? ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ayogasekaram will you be adding this section in a later PR? If so, I think it's good to go for now.