From a83f17b2044121f732967cc28495110ecee9a869 Mon Sep 17 00:00:00 2001 From: mstackhouse Date: Wed, 21 Feb 2024 14:10:07 +0000 Subject: [PATCH] Built site for Tplyr: 1.2.1@1fa6c4c --- articles/Tplyr.html | 12 ++--- articles/denom.html | 116 ++++++++++++++++++++++---------------------- pkgdown.yml | 2 +- search.json | 2 +- 4 files changed, 66 insertions(+), 66 deletions(-) diff --git a/articles/Tplyr.html b/articles/Tplyr.html index 288f35ef..4c7ed032 100644 --- a/articles/Tplyr.html +++ b/articles/Tplyr.html @@ -282,8 +282,8 @@

The tplyr_layer() Objectcnt <- group_count(t, AGEGR1) cnt #> *** count_layer *** -#> Self: count_layer < 0x55e11e2f54b0 > -#> Parent: tplyr_table < 0x55e11d707140 > +#> Self: count_layer < 0x55b20e8a83f0 > +#> Parent: tplyr_table < 0x55b20dcbab30 > #> target_var: #> AGEGR1 #> by: @@ -293,8 +293,8 @@

The tplyr_layer() Objectdsc <- group_desc(t, AGE) dsc #> *** desc_layer *** -#> Self: desc_layer < 0x55e11eb05c20 > -#> Parent: tplyr_table < 0x55e11d707140 > +#> Self: desc_layer < 0x55b20f0c0d88 > +#> Parent: tplyr_table < 0x55b20dcbab30 > #> target_var: #> AGE #> by: @@ -304,8 +304,8 @@

The tplyr_layer() Objectshf <- group_shift(t, vars(row=COMP8FL, column=COMP24FL)) shf #> *** shift_layer *** -#> Self: shift_layer < 0x55e11ecb0ef8 > -#> Parent: tplyr_table < 0x55e11d707140 > +#> Self: shift_layer < 0x55b20f267e18 > +#> Parent: tplyr_table < 0x55b20dcbab30 > #> target_var: #> COMP8FL #> COMP24FL diff --git a/articles/denom.html b/articles/denom.html index 0ec125fb..16154649 100644 --- a/articles/denom.html +++ b/articles/denom.html @@ -1678,32 +1678,32 @@

Missing Counts MILD -21 (55.26%) -70 (76.09%) +27 (65.85%) +70 (78.65%) 46 (47.92%) 1 1 MODERATE -17 (44.74%) -21 (22.83%) -46 (47.92%) +14 (34.15%) +19 (21.35%) +48 (50.00%) 1 2 SEVERE 0 ( 0.00%) -1 ( 1.09%) -4 ( 4.17%) +0 ( 0.00%) +2 ( 2.08%) 1 3 Missing -9 -19 +6 +22 22 1 Inf @@ -1909,8 +1909,8 @@

Adding a ‘Total’ RowF <65 8 ( 15.1%) -5 ( 12.5%) -5 ( 10.0%) +4 ( 10.0%) +4 ( 8.0%) 1 1 1 @@ -1918,9 +1918,9 @@

Adding a ‘Total’ Row F >80 -19 ( 35.8%) -7 ( 17.5%) -13 ( 26.0%) +17 ( 32.1%) +5 ( 12.5%) +12 ( 24.0%) 1 1 2 @@ -1928,9 +1928,9 @@

Adding a ‘Total’ Row F 65-80 -13 ( 24.5%) -24 ( 60.0%) -24 ( 48.0%) +18 ( 34.0%) +18 ( 45.0%) +23 ( 46.0%) 1 1 3 @@ -1938,9 +1938,9 @@

Adding a ‘Total’ Row F Missing -13 (24.5%) -4 (10.0%) -8 (16.0%) +10 (18.9%) +13 (32.5%) +11 (22.0%) 1 1 Inf @@ -1958,8 +1958,8 @@

Adding a ‘Total’ Row M <65 -5 ( 15.2%) -2 ( 4.5%) +3 ( 9.1%) +5 ( 11.4%) 2 ( 5.9%) 1 2 @@ -1969,8 +1969,8 @@

Adding a ‘Total’ RowM >80 7 ( 21.2%) -6 ( 13.6%) -11 ( 32.4%) +8 ( 18.2%) +12 ( 35.3%) 1 2 2 @@ -1979,8 +1979,8 @@

Adding a ‘Total’ RowM 65-80 16 ( 48.5%) -21 ( 47.7%) -16 ( 47.1%) +24 ( 54.5%) +18 ( 52.9%) 1 2 3 @@ -1988,9 +1988,9 @@

Adding a ‘Total’ Row M Missing -5 (15.2%) -15 (34.1%) -5 (14.7%) +7 (21.2%) +7 (15.9%) +2 ( 5.9%) 1 2 Inf @@ -2041,9 +2041,9 @@

Adding a ‘Total’ Row F All Age Groups -40 -36 -42 +43 +27 +39 1 1 -Inf @@ -2051,9 +2051,9 @@

Adding a ‘Total’ Row F <65 -8 ( 20.0%) -5 ( 13.9%) -5 ( 11.9%) +8 ( 18.6%) +4 ( 14.8%) +4 ( 10.3%) 1 1 1 @@ -2061,9 +2061,9 @@

Adding a ‘Total’ Row F >80 -19 ( 47.5%) -7 ( 19.4%) -13 ( 31.0%) +17 ( 39.5%) +5 ( 18.5%) +12 ( 30.8%) 1 1 2 @@ -2071,9 +2071,9 @@

Adding a ‘Total’ Row F 65-80 -13 ( 32.5%) -24 ( 66.7%) -24 ( 57.1%) +18 ( 41.9%) +18 ( 66.7%) +23 ( 59.0%) 1 1 3 @@ -2081,9 +2081,9 @@

Adding a ‘Total’ Row F Missing +10 13 -4 -8 +11 1 1 Inf @@ -2091,9 +2091,9 @@

Adding a ‘Total’ Row M All Age Groups -28 -29 -29 +26 +37 +32 1 2 -Inf @@ -2101,9 +2101,9 @@

Adding a ‘Total’ Row M <65 -5 ( 17.9%) -2 ( 6.9%) -2 ( 6.9%) +3 ( 11.5%) +5 ( 13.5%) +2 ( 6.2%) 1 2 1 @@ -2111,9 +2111,9 @@

Adding a ‘Total’ Row M >80 -7 ( 25.0%) -6 ( 20.7%) -11 ( 37.9%) +7 ( 26.9%) +8 ( 21.6%) +12 ( 37.5%) 1 2 2 @@ -2121,9 +2121,9 @@

Adding a ‘Total’ Row M 65-80 -16 ( 57.1%) -21 ( 72.4%) -16 ( 55.2%) +16 ( 61.5%) +24 ( 64.9%) +18 ( 56.2%) 1 2 3 @@ -2131,9 +2131,9 @@

Adding a ‘Total’ Row M Missing -5 -15 -5 +7 +7 +2 1 2 Inf diff --git a/pkgdown.yml b/pkgdown.yml index 7e46819e..c68e2d56 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -18,7 +18,7 @@ articles: sort: sort.html styled-table: styled-table.html table: table.html -last_built: 2024-02-21T14:02Z +last_built: 2024-02-21T14:08Z urls: reference: https://atorus-research.github.io/Tplyr/reference article: https://atorus-research.github.io/Tplyr/articles diff --git a/search.json b/search.json index 607e0eb2..dcc8b728 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement Mike.Stackhouse@atorusresearch.com. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.0, available https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. Community Impact Guidelines inspired Mozilla’s code conduct enforcement ladder. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://atorus-research.github.io/Tplyr/ISSUE_TEMPLATE.html","id":"prerequisites","dir":"","previous_headings":"","what":"Prerequisites","title":"NA","text":"information, see CONTRIBUTING guide.","code":""},{"path":"https://atorus-research.github.io/Tplyr/ISSUE_TEMPLATE.html","id":"description","dir":"","previous_headings":"","what":"Description","title":"NA","text":"[Description bug feature]","code":""},{"path":"https://atorus-research.github.io/Tplyr/ISSUE_TEMPLATE.html","id":"steps-to-reproduce-bug-report-only","dir":"","previous_headings":"","what":"Steps to Reproduce (Bug Report Only)","title":"NA","text":"[First Step] [Second Step] […] Expected behavior: [expected happen] Actual behavior: [actually happened]","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/ISSUE_TEMPLATE.html","id":"versions","dir":"","previous_headings":"","what":"Versions","title":"NA","text":"can get information executing sessionInfo().","code":""},{"path":"https://atorus-research.github.io/Tplyr/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"The MIT License (MIT)","title":"The MIT License (MIT)","text":"Copyright © 2020 Atorus Research LLC Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://atorus-research.github.io/Tplyr/PULL_REQUEST_TEMPLATE.html","id":"types-of-changes","dir":"","previous_headings":"","what":"Types of changes","title":"NA","text":"Bug fix (non-breaking change fixes issue) New feature (non-breaking change adds functionality) Breaking change (fix feature cause existing functionality change) read CONTRIBUTING document. code follows code style project. change requires change documentation. updated documentation accordingly. added tests cover changes. new existing tests passed.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"how-tplyr-works","dir":"Articles","previous_headings":"","what":"How Tplyr Works","title":"Getting Started","text":"look summary table within clinical report, can often break basic pieces. Consider output. Different variables summarized chunks table, refer “layers”. Additionally, table really contains different types summaries, makes many calculations rather redundant. drives motivation behind Tplyr. containing table encapsulated within tplyr_table() object, section, “layer”, within summary table can broken tplyr_layer() object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"the-tplyr_table-object","dir":"Articles","previous_headings":"How Tplyr Works","what":"The tplyr_table() Object","title":"Getting Started","text":"tplyr_table() object conceptual “table” contains logic necessary construct display data. Tplyr tables made one layers. layer contains instruction summary performed. tplyr_table() object contains layers, general data, metadata, logic necessary prepare data layers constructed. tplyr_table() created, contain following bindings: target - dataset upon summaries performed count_layer_formats - Default formats used count layers table shift_layer_formats - Default formats used shift layers table desc_layer_formats - Default formats used descriptive statistics layers table pop_data - dataset containing population information. defaults target dataset cols - categorical variable target dataset present summaries grouped column (addition treat_var variable) table_where - clause provided, used subset target dataset treat_var - Variable used distinguish treatment groups target dataset. header_n - Default header N values based treat_var cols variables pop_treat_var - Variable used distinguish treatment groups pop_data dataset (different treat_var variable target dataset) layers - container individual layers tplyr_table() treat_grps - Additional treatment groups added summary (.e. Total) function tplyr_table() allows basic interface instantiate object. Modifier functions available change individual parameters catered analysis.","code":"t <- tplyr_table(tplyr_adsl, TRT01P, where = SAFFL == \"Y\") t #> *** tplyr_table *** #> Target (data.frame): #> Name: tplyr_adsl #> Rows: 254 #> Columns: 49 #> treat_var variable (quosure) #> TRT01P #> header_n: header groups #> treat_grps groupings (list) #> Table Columns (cols): #> where: == SAFFL Y #> Number of layer(s): 0 #> layer_output: 0"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"the-tplyr_layer-object","dir":"Articles","previous_headings":"How Tplyr Works","what":"The tplyr_layer() Object","title":"Getting Started","text":"Users Tplyr interface tplyr_layer() objects using group_ family functions. family specifies type summary performed within layer. count layers used create summary counts discrete variable. shift layers summarize counts different changes states. Lastly, desc layers create descriptive statistics. Count layers allow easily create summaries based counting distinct non-distinct occurrences values within variable. Additionally, layer allows create n (%) summaries ’re also summarizing proportion instances value occurs compared denominator. Count layers also capable producing counts nested relationships. example, want produce counts overall outside group, subgroup counts within group, can simply specify target variable vars(OutsideVariable, InsideVariable). allows tables like Adverse Events want see Preferred Terms within Body Systems, one layer. Count layers can also distinguish distinct non-distinct counts. Using specified variable, can count unique occurrences variable within specified grouping, including target. allows summary like unique subjects proportion experiencing adverse event, number total occurrences adverse event. Descriptive statistics layers perform summaries continuous variables. number summaries built Tplyr already can perform, including n, mean, median, standard deviation, variance, min, max, interquartile range, Q1, Q3, missing value counts. available summaries, default presentation descriptive statistics layer output ‘n’, ‘Mean (SD)’, ‘Median’, ‘Q1, Q3’, ‘Min, Max’, ‘Missing’. can change summaries using set_format_strings(), can also add summaries using set_custom_summaries(). allows easily implement additional summary statistics want presented. Shift layers largely abstraction count layer - fact, re-use lot code process layers. many shift tables, “” state presented rows table, “” state presented columns. clearly lays many subjects changed state baseline point time. Shift layers give intuitive API break , using similar interface layers. also number modifier functions available control nuanced aspects, denominators applied.","code":"cnt <- group_count(t, AGEGR1) cnt #> *** count_layer *** #> Self: count_layer < 0x55e11e2f54b0 > #> Parent: tplyr_table < 0x55e11d707140 > #> target_var: #> AGEGR1 #> by: #> where: TRUE #> Layer(s): 0 dsc <- group_desc(t, AGE) dsc #> *** desc_layer *** #> Self: desc_layer < 0x55e11eb05c20 > #> Parent: tplyr_table < 0x55e11d707140 > #> target_var: #> AGE #> by: #> where: TRUE #> Layer(s): 0 shf <- group_shift(t, vars(row=COMP8FL, column=COMP24FL)) shf #> *** shift_layer *** #> Self: shift_layer < 0x55e11ecb0ef8 > #> Parent: tplyr_table < 0x55e11d707140 > #> target_var: #> COMP8FL #> COMP24FL #> by: #> where: TRUE #> Layer(s): 0"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"adding-layers-to-a-table","dir":"Articles","previous_headings":"How Tplyr Works","what":"Adding Layers to a Table","title":"Getting Started","text":"Everyone style coding - ’ve tried flexible extent. Overall, Tplyr built around tidy syntax, object construction supports piping magrittr (.e. %>%). two ways add layers tplyr_table(): add_layer() add_layers(). difference add_layer() allows construct layer within call add_layer(), whereas add_layers() can attach multiple layers already constructed upfront: Within add_layer(), syntax constructing count layer Age Categories written fly. add_layer() special also allows use piping use modifier functions layer constructed add_layers(), hand, lets isolate code construct particular layer wanted separate things . might find cleaner work large number layers constructed. Notice construct layers separately, need specify table belong. add_layer() automatically. tplyr_table() tplyr_layer() objects built environments, parent/child relationships important. , even though layer knows table parent , layers still need attached table (table doesn’t know children ). Advanced R good job explaining environments R , benefits, use .","code":"t <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories n (%)\") ) t <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories n (%)\") %>% set_format_strings(f_str(\"xx (xx.x%)\", n, pct)) %>% add_total_row() ) t <- tplyr_table(tplyr_adsl, TRT01P) l1 <- group_count(t, AGEGR1, by = \"Age categories n (%)\") l2 <- group_desc(t, AGE, by = \"Age (years)\") t <- add_layers(t, l1, l2)"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"a-note-before-we-go-deeper","dir":"Articles","previous_headings":"How Tplyr Works > Adding Layers to a Table","what":"A Note Before We Go Deeper","title":"Getting Started","text":"Notice construct tplyr_table() tplyr_layer() displays summary information table layer? ’s create objects - constructs metadata, process actual data. allows construct make sure pieces table fit together data processing - gives container hold metadata, use later necessary. generate data tplyr_table() object, use function build(): ’s can get Tplyr. ’s great formatted numbers, numeric data behind scenes? Maybe number looks suspicious need investigate got number. want calculate statistics based counts? can get information well using get_numeric_data(). returns numeric data layer list data frames: storing pertinent information, can get Tplyr object processed data display. specifying want get data Tplyr, can save repeatedly processing data constructing outputs - particularly useful computation starts taking time.","code":"t <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories n (%)\") ) t %>% build() %>% kable() get_numeric_data(t) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"constructing-layers","dir":"Articles","previous_headings":"How Tplyr Works","what":"Constructing Layers","title":"Getting Started","text":"bulk Tplyr coding comes constructing layers specifying work want done. get , ’s important discuss Tplyr handles string formatting.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"string-formatting-in-tplyr","dir":"Articles","previous_headings":"How Tplyr Works > Constructing Layers","what":"String Formatting in Tplyr","title":"Getting Started","text":"String formatting Tplyr controlled object called f_str(), also name function use create formats. set format strings tplyr_layer(), use function set_format_strings(), usage varies slightly layer types (covered vignettes). - object necessary. Consider example: perfect world, f_str() calls wouldn’t necessary - reality allow us infer great deal information user inputs. calls see : row labels row_label2 column taken left side = set_format_strings() string formats, including integer length decimal precision, exact presentation formatting taken strings within first parameter f_str() call n = Number observations mean = Mean sd = Standard Deviation var = Variance iqr = Inter Quartile Range q1 = 1st quartile q3 = 3rd quartile min = Minimum value max = Maximum value missing = Count NA values two summaries placed f_str() call, two summaries formatted string. allows “Mean (SD)” type format numbers appear. simple user input controls significant amount work back end data processing, f_str() object allows metadata collected. f_str() objects also used count layers well control data presentation. Instead specifying summaries performed, use n, pct, distinct_n, distinct_pct parameters specify like values displayed. Using distinct_n distinct_pct combined specifying distinct_by() variable using set_distinct_by(). Really - format strings allow present data however like. ? Probably .","code":"t <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE, by = \"Age (years)\") %>% set_format_strings( 'n' = f_str('xx', n), 'Mean (SD)' = f_str('xx.xx (xx.xxx)', mean, sd) ) ) t %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories\") %>% set_format_strings(f_str('xx (xx.x)',n,pct)) ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories\") %>% set_format_strings(f_str('xx',n)) ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories\") %>% set_format_strings(f_str('xx (•◡•) xx.x%',n,pct)) ) %>% build() %>% kable()"},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"descriptive-statistic-layers","dir":"Articles","previous_headings":"Layer Types","what":"Descriptive Statistic Layers","title":"Getting Started","text":"covered string formatting, set_format_strings() controls great deal happens within descriptive statistics layer. Note built defaults ’s output: override defaults, just specify summaries want performed using set_format_strings() described . Tplyr doesn’t built function summary statistic want see? Well - can make ! set_custom_summaries() comes play. Let’s say want derive geometric mean. set_custom_summaries(), first name summary performed. important - name use f_str() call incorporate format. Next, program call function desired. happens background used call dplyr::summarize() - use similar syntax. Use variable name .var custom summary function. necessary allows generic variable name used multiple target variables specified - therefore function can applied target variables. Sometimes ’s need present multiple variables summarized side side. Tplyr allows well. Tplyr summarizes variables merges together. makes creating tables need compare BASE, AVAL, CHG next nice simple. Note use dplyr::vars() - situation ’d like use multiple variable names parameter, use dplyr::vars() specify variables. can use text strings calls dplyr::vars() well.","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE, by = \"Age (years)\") ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE, by = \"Sepal Length\") %>% set_custom_summaries( geometric_mean = exp(sum(log(.var[.var > 0]), na.rm=TRUE) / length(.var)) ) %>% set_format_strings( 'Geometric Mean (SD)' = f_str('xx.xx (xx.xxx)', geometric_mean, sd) ) ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(vars(AGE, AVGDD), by = \"Age and Avg. Daily Dose\") ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"count-layers","dir":"Articles","previous_headings":"Layer Types","what":"Count Layers","title":"Getting Started","text":"Count layers generally allow create “n” “n (%)” count type summaries. extra features well. Let’s say want total row within counts. can done add_total_row(): Sometimes ’s also necessary count summaries based distinct values. Tplyr allows well set_distinct_by(): ’s another trick going - create summary row label text like see , text strings can used target variables. , use combination set_distinct_by() count distinct subjects. Adverse event tables often call counting AEs something like body system counting actual events within body system. Tplyr means making simple user well. use dplyr::vars() specify multiple target variables. used count layer, Tplyr knows automatically first variable grouping variable second variable, counts shall produced merged together.","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories\") %>% add_total_row() ) %>% build() %>% kable() tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count('Subjects with at least one adverse event') %>% set_distinct_by(USUBJID) %>% set_format_strings(f_str('xx', n)) ) %>% build() %>% kable() tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) ) %>% build() %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"shift-layers","dir":"Articles","previous_headings":"Layer Types","what":"Shift Layers","title":"Getting Started","text":"Lastly, let’s talk shift layers. common example looking subject’s lab levels baseline versus designated evaluation point. tell us, example, many subjects high baseline lab test vs. intervention introduced. shift layer Tplyr intended creating shift tables show data matrix, one state presented rows columns. Let’s look example. underlying process shift tables count layers - ’re counting number occurrences something set grouping variables. differs Tplyr uses group_shift() API use basic interface tables, translate target variables row variable column variable. Furthermore, enhanced control denominators behave necessary shift layer.","code":"# Tplyr can use factor orders to dummy values and order presentation tplyr_adlb$ANRIND <- factor(tplyr_adlb$ANRIND, c(\"L\", \"N\", \"H\")) tplyr_adlb$BNRIND <- factor(tplyr_adlb$BNRIND, c(\"L\", \"N\", \"H\")) tplyr_table(tplyr_adlb, TRTA, where = PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row=BNRIND, column=ANRIND), by=PARAM) %>% set_format_strings(f_str(\"xx (xxx%)\", n, pct)) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"where-to-go-from-here","dir":"Articles","previous_headings":"","what":"Where to go from here?","title":"Getting Started","text":"’s quite bit learn! ’ve prepared number vignettes help get need Tplyr. Learn table level settings vignette(\"table\") Learn descriptive statistics layers vignette(\"desc\") Learn count shift layers vignette(\"count\") Learn shift layers vignette(\"shift\") Learn calculating risk differences vignette(\"riskdiff\") Learn sorting Tplyr tables vignette(\"sort\") Learn using Tplyr options vignette(\"options\") finally, learn producing outputting styled tables using Tplyr vignette(\"styled-table\")","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Getting Started","text":"building Tplyr, needed additional resources addition personal experience help guide design. PHUSE done great work create guidance standard outputs collaboration multiple pharmaceutical companies FDA. can find resource referenced . Analysis Displays Associated Adverse Events Analyses Displays Associated Demographics, Disposition, Medications Analyses Displays Associated Measures Central Tendency","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/count.html","id":"a-simple-example","dir":"Articles","previous_headings":"","what":"A Simple Example","title":"Count Layers","text":"Let’s start basic example. table demonstrates distribution subject disposition across treatment groups. Additionally, ’re sorting descending total occurrences using “Total” group.","code":"t <- tplyr_table(tplyr_adsl, TRT01P, where = SAFFL == \"Y\") %>% add_total_group() %>% add_treat_grps(Treated = c(\"Xanomeline Low Dose\", \"Xanomeline High Dose\")) %>% add_layer( group_count(DCDECOD) %>% set_order_count_method(\"bycount\") %>% set_ordering_cols(Total) ) %>% build() %>% arrange(desc(ord_layer_1)) %>% select(starts_with(\"row\"), var1_Placebo, `var1_Xanomeline Low Dose`, `var1_Xanomeline High Dose`, var1_Treated, var1_Total) kable(t)"},{"path":"https://atorus-research.github.io/Tplyr/articles/count.html","id":"distinct-versus-event-counts","dir":"Articles","previous_headings":"","what":"Distinct Versus Event Counts","title":"Count Layers","text":"Another exceptionally important consideration within count layers whether using distinct counts, non-distinct counts, combination . Adverse event tables perfect example. Often, ’re concerned many subjects adverse event particular instead just number occurrences adverse event. Similarly, number occurrences event isn’t necessarily relevant compared total number adverse events occurred. reason, likely want look instead number subjects experienced event compared total number subjects treatment group. Tplyr allows focus distinct counts distinct percents within grouping variable, like subject. Additionally, can mix match distinct counts non-distinct counts row . set_distinct_by() function sets variables used calculate distinct occurrences value using specified distinct_by variables. may seen tables like one . display shows number subjects experienced adverse event, percentage subjects within given treatment group experienced event, total number occurrences event. Using set_distinct_by() triggered derivation distinct_n distinct_pct addition n pct created within group_count. display values controlled f_str() call set_format_strings(). additional option formatting numbers using ‘parenthesis hugging’. trigger , integer side number use capital ‘X’ capital ‘’. example: can seen , using parenthesis hugging, width specified format group preserved, preceding character (characters) left ‘X’ ‘’ pulled right ‘hug’ specified number.","code":"t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% set_format_strings(f_str(\"xxx (xx.xx%) [xxx]\", distinct_n, distinct_pct, n)) ) %>% build() %>% head() kable(t) t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% set_format_strings(f_str(\"xxx (XXX.xx%) [A]\", distinct_n, distinct_pct, n)) ) %>% build() %>% head() %>% select(row_label1, `var1_Xanomeline Low Dose`) t #> # A tibble: 6 × 2 #> row_label1 `var1_Xanomeline Low Dose` #> #> 1 ACTINIC KERATOSIS \" 0 (0.00%) [0]\" #> 2 ALOPECIA \" 0 (0.00%) [0]\" #> 3 BLISTER \" 5 (11.90%) [8]\" #> 4 COLD SWEAT \" 0 (0.00%) [0]\" #> 5 DERMATITIS ATOPIC \" 0 (0.00%) [0]\" #> 6 DERMATITIS CONTACT \" 1 (2.38%) [2]\""},{"path":"https://atorus-research.github.io/Tplyr/articles/count.html","id":"nested-count-summaries","dir":"Articles","previous_headings":"","what":"Nested Count Summaries","title":"Count Layers","text":"Certain summary tables present counts within groups. One example disposition table disposition reason “” summarizes reasons . common example Adverse Event table displays counts body systems, events within body systems. nuanced situation - two variables summarized: body system counts, advert event counts. One way approach creating two summaries. One summarizing body system, another summarizing preferred terms body system, merging two together. don’t want . Instead, handle complexity . done group_count() submitting two target variables dplyr::vars(). first variable grouping variable want summarized, refer “Outside” variable, second narrower scope, call “Inside” variable. example demonstrates nested summary. Look first row - row_label1 row_label2 “CARDIAC DISORDERS”. line summary AEBODSYS. rows , row_label1 continues value “CARDIAC DISORDERS”, row_label2 changes. summaries AEDECOD. accomplishes needed, ’s exactly presentation might hope . solution well. using set_nest_count(), triggers Tplyr drop row_label1, indent AEDECOD values within row_label2. columns renamed appropriately well. default indentation used 3 spaces, can see - can set indentation however like. let’s use tab strings different language-specific output types, stick spaces, indent wider smaller - whatever wish. existing order variables remain, impact ability sort table. ’s lot counting! sure check vignettes sorting, shift tables, denominators.","code":"tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) ) %>% build() %>% head() %>% kable() tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) %>% set_nest_count(TRUE) %>% set_indentation(\"--->\") ) %>% build() %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/custom-metadata.html","id":"build-a-tplyr_meta-object","dir":"Articles","previous_headings":"","what":"Build a tplyr_meta object","title":"Creating Custom Tplyr Metadata","text":"covered vignette('metadata'), tplyr_meta object consists two different fields: list variable names, list filter conditions. provide fields list quosures: tplyr_meta() function can take fields immediately upon creation. need dynamically create tplyr_meta object Tplyr constructs objects internally), functions add_variables() add_filters() available extend existing tplyr_meta object:","code":"m <- tplyr_meta( names = quos(a, b, c), filters = quos(a==1, b==2, c==3) ) m #> tplyr_meta: 3 names, 3 filters #> Names: #> a, b, c #> Filters: #> a == 1, b == 2, c == 3 m <- m %>% add_variables(quos(x)) %>% add_filters(quos(x == 'a')) m #> tplyr_meta: 4 names, 4 filters #> Names: #> a, b, c, x #> Filters: #> a == 1, b == 2, c == 3, x == \"a\""},{"path":"https://atorus-research.github.io/Tplyr/articles/custom-metadata.html","id":"building-your-own-metadata-table","dir":"Articles","previous_headings":"","what":"Building your own metadata table","title":"Creating Custom Tplyr Metadata","text":"Now can create tplyr_meta objects, let’s assemble metadata bottom portion Table 14-3.01: Let’s break happened : First, assemble overarching metadata object model. lot metadata shared across different result cells efficacy data, can start collecting information tplyr_meta object. Next, can use starting point build tplyr_meta objects result cells. model data contains contrasts different treatment group comparisons. using add_filters(), can create additional three tplyr_meta objects using starting point attaching additional filter condition. Lastly, extend metadata original tplyr_table object created summary portion table, need data frame. ’s lot ways , like display explicitness tibble::tribble(). building data frame use tplyr_table metadata, really two rules: need column data frame called row_id row_id values duplicates value within existing metadata. row_id values built Tplyr always follow format “n_n”, first letter layer type either “c”, “d”, “s”. next number layer number (.e. order layer inserted Tplyr table), finally row layer within output. example, third row count layer second layer table row_id “c2_3”. example, chose “x4_n” format “x” symbolize custom, data can thought fourth layer. said, values typically masked viewer table really just need unique - can choose whatever want.","code":"# Overall model subset of data meta <- tplyr_meta( names = quos(TRTP, EFFFL, ITTFL, ANL01FL, SITEGR1, AVISIT, AVISITN, PARAMCD, AVAL, BASE, CHG), filters = quos(EFFFL == \"Y\", ITTFL == \"Y\", PARAMCD == \"ACTOT\", ANL01FL == \"Y\", AVISITN == 24) ) # Xan High / Placebo contrast meta_xhp <- meta %>% add_filters(quos(TRTP %in% c(\"Xanomeline High Dose\", \"Placebo\"))) # Xan Low / Placbo Contrast meta_xlp <- meta %>% add_filters(quos(TRTP %in% c(\"Xanomeline Low Dose\", \"Placebo\"))) # Xan High / Xan Low Contrast meta_xlh <- meta %>% add_filters(quos(TRTP %in% c(\"Xanomeline High Dose\", \"Xanomeline Low Dose\"))) eff_meta <- tibble::tribble( ~\"row_id\", ~\"row_label1\", ~\"var1_Xanomeline Low Dose\", ~\"var1_Xanomeline High Dose\", \"x4_1\", \"p-value(Dose Response) [1][2]\", NULL, meta, \"x4_3\", \"p-value(Xan - Placebo) [1][3]\", meta_xlp, meta_xhp, \"x4_4\", \" Diff of LS Means (SE)\", meta_xlp, meta_xhp, \"x4_5\", \" 95% CI\", meta_xlp, meta_xhp, \"x4_7\", \"p-value(Xan High - Xan Low) [1][3]\", NULL, meta_xlh, \"x4_8\", \" Diff of LS Means (SE)\", NULL, meta_xlh, \"x4_9\", \" 95% CI\", NULL, meta_xlh )"},{"path":"https://atorus-research.github.io/Tplyr/articles/custom-metadata.html","id":"anti-joins","dir":"Articles","previous_headings":"Building your own metadata table","what":"Anti-joins","title":"Creating Custom Tplyr Metadata","text":"custom metadata ’re constructing requires references data outside target dataset, also possible tplyr_meta object. ’re looking non-overlap target dataset, can use anti-join. Anti-joins can added tplyr_meta object using add_anti_join() function.","code":"meta %>% add_anti_join( join_meta = tplyr_meta( names = quos(TRT01P, EFFFL, ITTFL, SITEGR1), filters = quos(EFFFL == \"Y\", ITTFL == \"Y\") ), on = quos(USUBJID) ) #> tplyr_meta: 11 names, 5 filters #> Names: #> TRTP, EFFFL, ITTFL, ANL01FL, SITEGR1, AVISIT, AVISITN, PARAMCD, AVAL, BASE, CHG #> Filters: #> EFFFL == \"Y\", ITTFL == \"Y\", PARAMCD == \"ACTOT\", ANL01FL == \"Y\", AVISITN == 24 #> Anti-join: #> Join Meta: #> tplyr_meta: 4 names, 2 filters #> Names: #> TRT01P, EFFFL, ITTFL, SITEGR1 #> Filters: #> EFFFL == \"Y\", ITTFL == \"Y\" #> On: #> USUBJID"},{"path":"https://atorus-research.github.io/Tplyr/articles/custom-metadata.html","id":"appending-existing-tplyr-metadata","dir":"Articles","previous_headings":"","what":"Appending Existing Tplyr Metadata","title":"Creating Custom Tplyr Metadata","text":"Now ’ve created custom extension Tplyr metadata, let’s extend existing data frame. , Tplyr function append_metadata(): Behind scenes, function simply binds new metadata old proper section tplyr_table object. can view tplyr_table metadata function get_metadata(): Finally, automatically created metadata Tplyr, can query result cells just :","code":"t <- append_metadata(t, eff_meta) get_metadata(t) #> # A tibble: 16 × 6 #> row_id row_label1 row_label2 var1_Placebo var1_Xanomeline High…¹ #> #> 1 d1_1 \"Baseline\" n #> 2 d2_1 \"Baseline\" Mean (SD) #> 3 d3_1 \"Baseline\" Median (R… #> 4 d1_2 \"Week 24\" n #> 5 d2_2 \"Week 24\" Mean (SD) #> 6 d3_2 \"Week 24\" Median (R… #> 7 d1_3 \"Change from Baseline\" n #> 8 d2_3 \"Change from Baseline\" Mean (SD) #> 9 d3_3 \"Change from Baseline\" Median (R… #> 10 x4_1 \"p-value(Dose Response… NA #> 11 x4_3 \"p-value(Xan - Placebo… NA #> 12 x4_4 \" Diff of LS Means (… NA #> 13 x4_5 \" 95% CI\" NA #> 14 x4_7 \"p-value(Xan High - Xa… NA #> 15 x4_8 \" Diff of LS Means (… NA #> 16 x4_9 \" 95% CI\" NA #> # ℹ abbreviated name: ¹​`var1_Xanomeline High Dose` #> # ℹ 1 more variable: `var1_Xanomeline Low Dose` get_meta_subset(t, 'x4_1', \"var1_Xanomeline High Dose\") %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/custom-metadata.html","id":"metadata-without-tplyr","dir":"Articles","previous_headings":"","what":"Metadata Without Tplyr","title":"Creating Custom Tplyr Metadata","text":"well may scenario want use metadata functions outside Tplyr general. , S3 methods available query metadata dataframe instead Tplyr table, parameters provide target data frame: Tplyr metadata, strict criteria custom metadata row_id column.","code":"get_meta_subset(eff_meta, 'x4_1', \"var1_Xanomeline High Dose\", target=tplyr_adas) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/custom-metadata.html","id":"tying-it-together","dir":"Articles","previous_headings":"","what":"Tying it Together","title":"Creating Custom Tplyr Metadata","text":"vignette wouldn’t complete without final contextual example - go. Ultimately pieces fit together context Shiny application give desired click-experience. Source code available ","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"population-data-in-the-denominator","dir":"Articles","previous_headings":"","what":"Population Data in the Denominator","title":"Totals, Missings, and Denominators","text":"target dataset doesn’t information necessary create denominator? example - create adverse event table, adverse event dataset likely contains records subjects experienced adverse event. subjects adverse event still part study population must considered denominator. reason,Tplyr allows lets set separate population dataset - couple things need trigger Tplyr use population data denominator. Consider two examples. three things done use population data: Population data must set first place using set_pop_where() population treatment variable must specified using set_pop_treat_var() set_distinct_by() must used. ? need use separate population dataset, target dataset likely one record per subject. set_distinct_by() scenario used get distinct counts per subject. example, ’re looking number unique subjects experienced specific adverse event. population denominator used calculating distinct_pct. also worth noting default count layer formats use distinct values. Note need control values used denominator population data, can set separate filter population data used set_pop_where(). Fortunately, denominators much simpler ’re kept within single dataset. Just kidding! Let’s get weird.","code":"tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% set_format_strings(f_str('xx (xx.x%)', distinct_n, distinct_pct)) ) %>% build() %>% head() %>% kable() tplyr_table(tplyr_adae, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% set_format_strings(f_str('xx (xx.x%)', distinct_n, distinct_pct)) ) %>% build() %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"denominator-grouping","dir":"Articles","previous_headings":"","what":"Denominator Grouping","title":"Totals, Missings, and Denominators","text":"’re looking within single dataset, couple factors need consider denominator. first grouping variables create denominators. Let’s look two perspectives - count layers shift layers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"count-layers","dir":"Articles","previous_headings":"Denominator Grouping","what":"Count layers","title":"Totals, Missings, and Denominators","text":"complexity denominators comes nuanced situations. solid 80% time, defaults work. example, frequency table, typically want data within column sum 100%. example: default, using population data strategy shown , count layer assumes want columns sum 100%. ’s always case. Perhaps ’d like break summary sex presented row-wise. Ok - , now little bit . breaking sex row group, denominators still total treatment group. make sense? 34 female Placebo group subjects completed, calculated 39.5% also includes male subjects denominator. Let’s fix using set_denoms_by(). Ok - much better. set_denoms_by() now changed denominator grouping us, denominator used 34 female Placebo subjects now total number female Placebo subjects. Makes sense, right? set_denoms_by() allows specify: treatment variable cols variables specified table level variables specified layer level Depending presentation, require may change - flexibility choose need.","code":"tplyr_adsl <- tplyr_adsl %>% mutate(DCSREAS = ifelse(DCSREAS == '', 'Completed', DCSREAS)) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(DCSREAS) ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(DCSREAS, by=SEX) ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(DCSREAS, by=SEX) %>% set_denoms_by(SEX, TRT01P) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"shift-layers","dir":"Articles","previous_headings":"Denominator Grouping","what":"Shift layers","title":"Totals, Missings, and Denominators","text":"major part shift API control denominators used calculation percentages. shift tables, percentages relative “box” formed “” “” groups shift treatment group. Just like count layers, set_denoms_by() functions variable name treatment variable, cols argument, variables. difference shift layers now can also include target variables used row column. example , denominators based treatment variables, TRTA, PARAM VISIT. creates 3 X 3 box, denominator total record within shift variables, within parameter, visit, treatment. default, Tplyr create denominators set_denoms_by() isn’t specified. next example, percentage denominators calculated row-wise, row percentage sums 100%. practical, last example denominators changed based entire column instead 3 x 3 box. passing column variables, TRTA ANRIND layer use denominators determining percentages. hope gives flexibility need structure denominator however required.","code":"tplyr_table(tplyr_adlb, TRTA, where=PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, AVISIT)) %>% set_format_strings(f_str(\"xx (xxx.x%)\", n, pct)) %>% # This is the default, the 3x3 box formed by the target variables set_denoms_by(TRTA, PARAM, AVISIT) ) %>% build() %>% kable() tplyr_table(tplyr_adlb, TRTA, where=PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, AVISIT)) %>% set_format_strings(f_str(\"xx (xxx.x%)\", n, pct)) %>% set_denoms_by(TRTA, PARAM, AVISIT, BNRIND) # Each row made by TRTA, BNRIND ) %>% build() %>% arrange(ord_layer_1, ord_layer_2, ord_layer_3) %>% head() %>% kable() tplyr_table(tplyr_adlb, TRTA, where = PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, AVISIT)) %>% set_format_strings(f_str(\"xx (xx.xx%)\", n, pct)) %>% set_denoms_by(TRTA, ANRIND) # Use the column total as the denominator ) %>% build() %>% arrange(ord_layer_1, ord_layer_2, ord_layer_3) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"controlling-the-denominator-filter","dir":"Articles","previous_headings":"","what":"Controlling the Denominator Filter","title":"Totals, Missings, and Denominators","text":"circumstances ’ll encounter filter used denominator needs different filter used count. Disposition tables example , ’ll use example paint picture. Tplyroffers ability specifically control filter used within denominator. provided function set_denom_where(). default set_denom_where() layer level parameter, one supplied. set_denom_where() allows replace layer level filter custom filter choosing. done top filtering specified tplyr_table() parameter - means set_denom_where() filter applied addition table level filtering. Yeah know - lot different places filtering can happen… let’s take example shown . first layer layer level filtering applied, table level filter applied. second layer layer level filter applied, denominators based layer level filter. Notice case, percentages second layer add 100%. denominator includes values used layer. third layer layer level filter applied, additionally uses set_denom_where(). set_denom_where() example actually removing layer level filter denominators. R, filter using TRUE, filter returns records. using TRUE set_denom_where(), layer level filter effectively removed. causes denominator include values available table just selected layer - layer, percentages add 100%. important - allows percentages Layer 3 sum total percentage “DISCONTINUED” Layer 1.","code":"tplyr_adsl2 <- tplyr_adsl %>% mutate(DISCONTEXT = if_else(DISCONFL == 'Y', 'DISCONTINUED', 'COMPLETED')) t <- tplyr_table(tplyr_adsl2, TRT01P, where = SAFFL == 'Y') %>% add_layer( group_count(DISCONTEXT) ) %>% add_layer( group_count(DCSREAS, where = DISCONFL == 'Y') ) %>% add_layer( group_count(DCSREAS, where = DISCONFL == 'Y') %>% set_denom_where(TRUE) ) %>% build() %>% arrange(ord_layer_index, ord_layer_1) t %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"missing-counts","dir":"Articles","previous_headings":"","what":"Missing Counts","title":"Totals, Missings, and Denominators","text":"Missing counts tricky area frequency tables, play directly denominators well. values raise number questions. example, want format missing counts way event counts? want present missing counts percentages? missing counts belong denominator? set_missing_count() function can take new f_str() object set display missing values. specified, associated count layer’s format used. Using ... parameter, able specify row label desired missing values values determine considered ‘missing’. example, may NA values target variable, values like “Collected” also wish consider “missing”. set_missing_count() allows group together. Actually - ’re able establish many different “missing” groups want - even though scenario fairly unlikely. example 50 random values removed NA specified missing string. leads us another parameter - denom_ignore. default, specify missing values still considered within denominator, missing counts, may wish exclude totals summarized. setting denom_ignore TRUE, denominators ignore groups missing values ’ve specified. one thing worth explaining example - gave missing count sort value. leave field null, simply maximum value order layer plus 1, put Missing counts bottom ascending sort. tables can sorted lot different ways, ’ll see sort vignette. instead trying come novel ways control missing row goes - decided just let specify value.","code":"tplyr_adae2 <- tplyr_adae tplyr_adae2[sample(nrow(tplyr_adae2), 50), \"AESEV\"] <- NA t <- tplyr_table(tplyr_adae2, TRTA) %>% add_layer( group_count(AESEV) %>% set_format_strings(f_str(\"xxx (xx.xx%)\", n, pct)) %>% set_missing_count(f_str(\"xxx\", n), sort_value=Inf, denom_ignore=TRUE, Missing = NA) ) %>% build() %>% arrange(ord_layer_1) t %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"missing-subjects","dir":"Articles","previous_headings":"","what":"Missing Subjects","title":"Totals, Missings, and Denominators","text":"Missing counts counting missing subjects work two different ways within Tplyr. Missing counts, described , examine records present data collect missing values. results counted, need first provided within input data . hand, missing subjects calculated looking difference potential number subjects within column (.e. combination treatment variables column variables) number subjects actually present. Consider example: example , produce nested count layer. function add_missing_subjects_row() triggers addition new result row missing subjects calculated. row label applied can configured using set_missing_subjects_row_label(), row label default ‘Missing’. Depending sorting needs, sort_value can applied whatever numeric value provide. Lastly, can provide f_str() format missing subjects row separately rest layer, whatever format applied layer apply otherwise. Note nested count layers, missing subject rows generate independent group within outer layer. Outer layers missing subject rows calculated individually. best done independent layer , result apply whole input target dataset.","code":"missing_subs <- tplyr_table(tplyr_adae, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) %>% set_nest_count(TRUE) %>% set_distinct_by(USUBJID) %>% add_missing_subjects_row(f_str(\"xx (XX.x%)\", distinct_n, distinct_pct), sort_value = Inf) %>% set_missing_subjects_row_label(\"Missing Subjects\") ) %>% build() tail(missing_subs) %>% select(-starts_with('ord')) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"adding-a-total-row","dir":"Articles","previous_headings":"","what":"Adding a ‘Total’ Row","title":"Totals, Missings, and Denominators","text":"addition missing counts, summaries require addition ‘Total’ row. Tplyr helper function add_total_row() ease process . Like things within Tplyr - particularly vignette - significant bit nuance . Much functionality similar set_missing_count(). ’re able specify different format total, specified, associated count layer’s format used. ’re able set sort value specify want total row sit. nuance comes two places: default, add_total_row() count missing values, can exclude values using count_missings parameter. Tplyr warn set_count_missing() denom_ignore set TRUE, add_total_row() count_missings set TRUE format contains percentage. ? denominator ignoring missing values ’re still counting total, percentage shown can exceed 100%. add_total_row() throw warning variable used, becomes ambiguous total calculated. can rectify using set_denoms_by(), allows user control exactly groups used form denominator. way totals presented add_total_row() align denominators specified set_denom_by() generate total rows match grouping denominator values. example , summarize age groups sex. denominators determined treatment group sex, since excluding values denominator, total row ends matching denominator used. ‘Missing’ row tells us number missing values, count_missings set TRUE, missing counts included total row. probably isn’t choose display things, ’re trying show flexibility built Tplyr. default text Total row “Total”, provide set_total_row_label() allow customize text used display. Let’s look practical version table . display missings, probably want exclude total. using set_missing_count(). commonly, ’ll see : Now table intuitive. used set_missing_count() update denominators, missing excluded. Now, total row intuitively matches denominators used within group, can see many missing records excluded. may stumbled upon portion vignette searching create total column. Tplyr allows well function add_total_group() read vignette(\"table\"). ’s denominators! Happy counting!","code":"tplyr_adsl2 <- tplyr_adsl tplyr_adsl2[sample(nrow(tplyr_adsl2), 50), \"AGEGR1\"] <- NA tplyr_table(tplyr_adsl2, TRT01P) %>% add_layer( group_count(AGEGR1, by=SEX) %>% set_denoms_by(TRT01P, SEX) %>% # This gives me a Total row each group add_total_row(f_str(\"xxx\", n), count_missings=TRUE, sort_value=-Inf) %>% set_total_row_label(\"All Age Groups\") %>% set_missing_count(f_str(\"xx (xx.x%)\", n, pct), Missing = NA, sort_value=Inf) ) %>% build() %>% arrange(ord_layer_1, ord_layer_2) %>% kable() tplyr_table(tplyr_adsl2, TRT01P) %>% add_layer( group_count(AGEGR1, by=SEX) %>% set_denoms_by(TRT01P, SEX) %>% # This gives me a Total row each group add_total_row(f_str(\"xxx\", n), count_missings=FALSE, sort_value=-Inf) %>% set_total_row_label(\"All Age Groups\") %>% set_missing_count(f_str(\"xxx\", n), Missing = NA, sort_value=Inf, denom_ignore=TRUE) ) %>% build() %>% arrange(ord_layer_1, ord_layer_2) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/desc.html","id":"built-in-summaries","dir":"Articles","previous_headings":"","what":"Built-in Summaries","title":"Descriptive Statistic Layers","text":"’ve built number default summaries Tplyr, allows perform summaries without specify functions calculate . summaries built Tplyr listed . second column names use within f_str() call use . third column, syntax used make function call.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/desc.html","id":"notes-about-built-ins","dir":"Articles","previous_headings":"Built-in Summaries","what":"Notes About Built-in’s","title":"Descriptive Statistic Layers","text":"Note non-default option used function calls na.rm=TRUE. ’s important note min max, na.rm=TRUE used vector NA, functions return Inf -Inf respectively. formatting numbers, unexpected also inconsistent descriptive statistic functions, return NA. Therefore, just min max, Inf’s converted NA ’ll align behavior empty parameter f_str(). Using default settings descriptive statistic functions typically fine, IQR, Q1, Q3 note several different quantile algorithms available R. default chose use R default Type 7: \\[ m = 1-p. p[k] = (k - 1) / (n - 1). \\textrm{case, } p[k] = mode[F(x[k])]. \\textrm{used S.} \\] said, still want offer flexibility , can change quantile algorithm switching tplyr.quantile_type option. ’re intending match SAS definition, can use Type 3. information, see stats::quantile() documentation. example demonstrates using default quantile algorithm R. next example demonstrates using quantile algorithm Type 3, matches SAS definition : \\[ \\textrm{Nearest even order statistic. γ = 0 g = 0 j even, 1 otherwise.} \\] ’s determine algorithm use - found necessary provide flexibility change within default summaries. Tplyr doesn’t offer summaries need?","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(CUMDOSE) %>% set_format_strings(\"Q1, Q3\" = f_str('xxxxx, xxxxx', q1, q3)) ) %>% build() %>% select(-starts_with(\"ord\")) %>% kable() options(tplyr.quantile_type = 3) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(CUMDOSE) %>% set_format_strings(\"Q1, Q3\" = f_str('xxxxx, xxxxx', q1, q3)) ) %>% build() %>% select(-starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/desc.html","id":"custom-summaries","dir":"Articles","previous_headings":"","what":"Custom Summaries","title":"Descriptive Statistic Layers","text":"understand defaults may cover every descriptive statistic ’d like see. ’s ’ve opened door creating custom summaries. Custom summaries allow provide function ’d like desc layer. can focus derivation calculate number want see. Tplyr can consume function, use existing tools within Tplyr produce string formatted result alongside default summaries provide well. Custom summaries may provided two ways: tplyr.custom_summaries option set session level function set_custom_summaries() layer level setting Tplyr, layer setting always take precedence setting. Let’s look example. , important things demonstrated: multi-variable descriptive statistics layer. AGE HEIGHTBL summarized layer. AGE results go var1_ variables HEIGHTBL results go var2_ variables. parameter names set_custom_summaries(), names left side equals, flow set_format_strings() f_str() calls. Just like default summaries, geometric_mean becomes name refer order use geometric mean derivation summary. geometric mean, target variable ’re summarizing referred .var. may seem intuitive. reason use .var , like example, custom function can applied separate target variables. Another note custom summaries ’re able overwrite default summaries built Tplyr well. Don’t like default summary functions provide? Use tplyr.custom_summaries option overwrite session, add new ones like include. example, use Tplyr default mean. now, let’s overwrite mean using custom summary. Let’s use trimmed mean instead, taking 20% observations ends. Note table code used produce output . Now Tplyr used custom summary function mean specified tplyr.custom_summaries option. Also note use rlang::quos(). ’ve done best mask user everywhere possible make interfaces clean intuitive, great deal Tplyr built using ‘rlang’ non-standard evaluation. Within option one instances user needs concern use quosures. ’d like learn non-standard evaluation quosures, recommend Section IV Advanced R.","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(vars(AGE, HEIGHTBL), by = \"Sepal Length\") %>% set_custom_summaries( geometric_mean = exp(sum(log(.var[.var > 0]), na.rm=TRUE) / length(.var)) ) %>% set_format_strings( 'Geometric Mean (SD)' = f_str('xx.xx (xx.xxx)', geometric_mean, sd) ) ) %>% build() %>% select(-starts_with(\"ord\")) %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE) %>% set_format_strings(\"Mean\" = f_str('xx.xx', mean)) ) %>% build() %>% kable() options(tplyr.custom_summaries = rlang::quos( mean = mean(.var, na.rm=TRUE, trim=0.4) ) ) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE) %>% set_format_strings(\"Mean\" = f_str('xx.xx', mean)) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/desc_layer_formatting.html","id":"empty-value-formatting","dir":"Articles","previous_headings":"","what":"Empty Value Formatting","title":"Advanced Descriptive Statistic Layer Formatting","text":"default, available value summary particular observation, result presented blanked . Note: Tplyr generally respects factor levels - instances missing row column group, factor level present, variable row still generate) Note entire example records var1_Placebo missing. Tplyr gives control fill space. Let’s say wanted instead make space say “Missing”. can control f_str() object using empty parameter. Look empty parameter . , use named character vector, name .overall. name used, elements within cell missing, filled specified text. Otherwise, provided string fill just missing parameter. cases, may ’d like see. Perhaps want string fills missing space. example , instead filling whole space, empty text “NA” replaces empty value element. ‘Mean (SD)’, now ‘NA ( NA)’. Note proper padding still used ‘NA’ make sure parentheses still align populated records.","code":"tplyr_adsl$TRT01P <- as.factor(tplyr_adsl$TRT01P) tplyr_adlb$TRTA <- as.factor(tplyr_adlb$TRTA) tplyr_adlb_2 <- tplyr_adlb %>% filter(TRTA != \"Placebo\") tplyr_table(tplyr_adlb_2, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01P) %>% add_layer( group_desc(AVAL, by=PARAMCD) %>% set_format_strings('Mean (SD)' = f_str('xxx (xxx)', mean, sd)) ) %>% build() %>% head() %>% select(-starts_with(\"ord\")) %>% kable() tplyr_table(tplyr_adlb_2, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01P) %>% add_layer( group_desc(AVAL, by=PARAMCD) %>% set_format_strings('Mean (SD)' = f_str('xxx.xx (xxx.xxx)', mean, sd, empty=c(.overall=\"MISSING\"))) ) %>% build() %>% head() %>% select(-starts_with(\"ord\")) %>% kable() tplyr_table(tplyr_adlb_2, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01P) %>% add_layer( group_desc(AVAL, by=PARAMCD) %>% set_format_strings('Mean (SD)' = f_str('xxx.xx (xxx.xxx)', mean, sd, empty=c(\"NA\"))) ) %>% build() %>% head() %>% select(-starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/desc_layer_formatting.html","id":"auto-precision","dir":"Articles","previous_headings":"","what":"Auto Precision","title":"Advanced Descriptive Statistic Layer Formatting","text":"may noticed approach formatting covered far leaves lot desired. Consider analyzing lab results, may want precision vary based collected precision tests. Furthermore, depending summary presented, may wish increase precision . example, may want mean collected precision +1 decimal place, standard deviation +2. Tplyr covered using auto-precision. Auto-precision allows format numeric summaries based precision data collected. built format strings, natural place specify desired format specify want data presented. wish use auto-precision, use instead x creating summaries. Note one needed side decimal. use increased precision, use +n n number additional spaces wish add. can see, decimal precision now varying depending test performed. Notice integer decimal side number fluctuate well. Tplyr collects integer decimal precision, can specify separately. example, use x’s specify default number spaces integers used consistently across variables, vary decimal precision based collected data. can also increment number spaces integer decimal separately. - kind ugly, isn’t ? really need 6 decimal places collected CA? reason, ’re able set cap precision ’s displayed: Now looks better. cap argument part set_format_strings(). need specify integer decimal caps separately. Note integer precision works slightly differently decimal precision. Integer precision relates length allotted left side decimal, integers truncate. using ‘x’ formatting, integer exceeds set length, push number . integer side auto-precision capped, necessary length integer associated group long necessary. Decimals, hand, round specified length. caps apply length allotted “” either integer decimal. example, decimal length capped 2 selected precision “+1”, 3 decimal places allotted. basic situation, ’re paying close attention, may questions. variables, like visit test. calculate precision visit test? collected precision different per visit don’t want ? multiple summary variables? determine precision ? modifier functions : Three variables summarized - AVAL, CHG, BASE. used precision? set_precision_on() allows specify , precision_on() variable must one variables within target_var. Similarly, set_precision_by() changes variables used determine collected precision. precision_on() variable specified, first variable target_var used. precision_by variables specified, default variables used.","code":"tplyr_table(tplyr_adlb, TRTA) %>% add_layer( group_desc(AVAL, by = PARAMCD) %>% set_format_strings( 'Mean (SD)' = f_str('a.a+1 (a.a+2)', mean, sd) ) ) %>% build() %>% head(20) %>% select(-starts_with(\"ord\")) %>% kable() tplyr_table(tplyr_adlb, TRTA) %>% add_layer( group_desc(AVAL, by = PARAMCD) %>% set_format_strings( 'Mean (SD)' = f_str('a.a+1 (a.a+2)', mean, sd), cap = c(int=3, dec=2) ) ) %>% build() %>% head(20) %>% select(-starts_with(\"ord\")) %>% kable() tplyr_table(tplyr_adlb, TRTA) %>% add_layer( group_desc(vars(AVAL, CHG, BASE), by = PARAMCD) %>% set_format_strings( 'Mean (SD)' = f_str('a.a+1 (a.a+2)', mean, sd, empty=\"NA\"), cap = c(int=3, dec=2) ) %>% set_precision_on(AVAL) %>% set_precision_by(PARAMCD) ) %>% build() %>% head() %>% select(-starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/desc_layer_formatting.html","id":"external-precision","dir":"Articles","previous_headings":"","what":"External Precision","title":"Advanced Descriptive Statistic Layer Formatting","text":"Lastly, dynamic precision might ’re looking , may want precision driven data. Perhaps ’s company standard dictates decimal precision used separate lab test. Maybe even deeper lab test category. New Tplyr 1.0.0 ’ve added ability take decimal precision external source. principal external precision exactly auto-precision. difference - user - provide precision table Tplyr automatically calculating background. done using new function set_precision_data(). output , Notice precision PARAMCD varies depending specified data frame prec_data. one variable groups missing precision data, Tplyr can default back using auto-precision using option default=auto.","code":"prec_data <- tibble::tribble( ~PARAMCD, ~max_int, ~max_dec, \"BUN\", 1, 0, \"CA\", 2, 4, \"CK\", 3, 1, \"GGT\", 3, 0, \"URATE\", 3, 1, ) tplyr_table(tplyr_adlb, TRTA) %>% add_layer( group_desc(AVAL, by = PARAMCD) %>% set_format_strings( 'Mean (SD)' = f_str('a.a+1 (a.a+2)', mean, sd, empty=\"NA\") ) %>% set_precision_on(AVAL) %>% set_precision_by(PARAMCD) %>% set_precision_data(prec_data) ) %>% build() %>% head() %>% select(-starts_with(\"ord\")) %>% kable() prec_data <- tibble::tribble( ~PARAMCD, ~max_int, ~max_dec, \"BUN\", 1, 0, \"CA\", 2, 4, \"CK\", 3, 1, \"GGT\", 3, 0, ) tplyr_table(tplyr_adlb, TRTA) %>% add_layer( group_desc(AVAL, by = PARAMCD) %>% set_format_strings( 'Mean (SD)' = f_str('a.a+1 (a.a+2)', mean, sd, empty=\"NA\") ) %>% set_precision_on(AVAL) %>% set_precision_by(PARAMCD) %>% set_precision_data(prec_data, default=\"auto\") ) %>% build() %>% head() %>% select(-starts_with(\"ord\")) %>% kable() #> Unhandled precision cases were found - calculating precision based on source data"},{"path":"https://atorus-research.github.io/Tplyr/articles/desc_layer_formatting.html","id":"parenthesis-hugging","dir":"Articles","previous_headings":"","what":"Parenthesis Hugging","title":"Advanced Descriptive Statistic Layer Formatting","text":"default, using ‘x’ ‘’, character within format string stay stationary. Consider standard example descriptive statistic layer vignette. Note certain number integers alotted, space left numbers fill space, position parenthesis stays fixed. displays, may want parenthesis ‘hug’ number - “format group” width stay fixed, parenthesis move right along numbers consuming less integer space. Within f_str(), can achieve using capital ‘X’. example, focusing mean standard deviation line: Similarly, functionality works auto precision using capital . two rules using ‘parenthesis hugging’: Capital letters used integer side number character must precede capital letter, otherwise ’s character ‘hug’ Aside rules, parenthesis hugging can combined valid format string capabilities.","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE, by = \"Age (years)\", where= SAFFL==\"Y\") %>% set_format_strings( \"n\" = f_str(\"xx\", n), \"Mean (SD)\"= f_str(\"xx.x (xx.xx)\", mean, sd), \"Median\" = f_str(\"xx.x\", median), \"Q1, Q3\" = f_str(\"xx, xx\", q1, q3), \"Min, Max\" = f_str(\"xx, xx\", min, max), \"Missing\" = f_str(\"xx\", missing) ) ) %>% build() %>% select(-starts_with('ord')) #> # A tibble: 6 × 5 #> row_label1 row_label2 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 Age (years) n \"86\" \"84\" #> 2 Age (years) Mean (SD) \"75.2 ( 8.59)\" \"74.4 ( 7.89)\" #> 3 Age (years) Median \"76.0\" \"76.0\" #> 4 Age (years) Q1, Q3 \"69, 82\" \"71, 80\" #> 5 Age (years) Min, Max \"52, 89\" \"56, 88\" #> 6 Age (years) Missing \" 0\" \" 0\" #> # ℹ 1 more variable: `var1_Xanomeline Low Dose` tplyr_table(tplyr_adlb, TRTA, PARAMCD == \"CK\") %>% add_layer( group_desc(AVAL, by=vars(PARAMCD, AVISIT)) %>% set_format_strings( TEST = f_str(\"xxx.x (XXX.x)\", mean, sd, empty=\"NA\") ) %>% set_precision_by(PARAMCD) ) %>% build() %>% head() %>% select(-starts_with('ord')) #> # A tibble: 3 × 6 #> row_label1 row_label2 row_label3 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 CK Week 12 TEST 140.0 (148.6) \"140.1 (115.5)\" #> 2 CK Week 24 TEST 246.6 (438.5) \" 55.5 (3.5)\" #> 3 CK Week 8 TEST 116.0 (78.9) \" 93.3 (80.6)\" #> # ℹ 1 more variable: `var1_Xanomeline Low Dose` tplyr_table(tplyr_adlb, TRTA, PARAMCD == \"CK\") %>% add_layer( group_desc(AVAL, by=vars(PARAMCD, AVISIT)) %>% set_format_strings( TEST = f_str(\"a.a (A.a)\", mean, sd, empty=\"NA\") ) %>% set_precision_by(PARAMCD) ) %>% build() %>% head() %>% select(-starts_with('ord')) #> # A tibble: 3 × 6 #> row_label1 row_label2 row_label3 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 CK Week 12 TEST \" 140 (149)\" \" 140 (115)\" #> 2 CK Week 24 TEST \" 247 (438)\" \" 56 (4)\" #> 3 CK Week 8 TEST \" 116 (79)\" \" 93 (81)\" #> # ℹ 1 more variable: `var1_Xanomeline Low Dose` "},{"path":"https://atorus-research.github.io/Tplyr/articles/general_string_formatting.html","id":"format-strings","dir":"Articles","previous_headings":"","what":"Format Strings","title":"General String Formatting","text":"Regardless layer type use within Tplyr, control formatting handled using format strings. Consider following example. layer type, want configure string formatting use function set_format_strings(). Inside set_format_strings() provide f_str() objects. Within count layers, basic tables can just provide singe f_str() object control general formatting. descriptive statistic layers, provide named parameters, names become values row_label1 statistics provided within f_str() object. Regardless layer type, f_str() object controls numbers reported resulting table. table outlines variables available within layer. Note: actual equations used descriptive statistics layers, see vignettes(\"desc\")","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE) %>% set_format_strings( f_str(\"xx (xx.x%)\", n, pct) ) ) %>% add_layer( group_desc(AGE) %>% set_format_strings( \"Mean (SD)\" = f_str(\"xx.x (xx.xx)\", mean, sd) ) ) %>% build() %>% select(1:3) #> # A tibble: 4 × 3 #> row_label1 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 AMERICAN INDIAN OR ALASKA NATIVE \" 0 ( 0.0%)\" \" 1 ( 1.2%)\" #> 2 BLACK OR AFRICAN AMERICAN \" 8 ( 9.3%)\" \" 9 (10.7%)\" #> 3 WHITE \"78 (90.7%)\" \"74 (88.1%)\" #> 4 Mean (SD) \"75.2 ( 8.59)\" \"74.4 ( 7.89)\""},{"path":"https://atorus-research.github.io/Tplyr/articles/general_string_formatting.html","id":"general-formatting","dir":"Articles","previous_headings":"","what":"General Formatting","title":"General String Formatting","text":"Looking back Tplyr table , let’s look count layer’s f_str() call. can see print method f_str() object capture “format string”, xx (xx.x%), metadata surrounding . string details exactly numbers placed within output result result look like. done breaking string “format groups”, separate numeric fields surrounding characters within format string. format string, xx (xx.x%), two different format groups. first field xx, attaches variable n. second (xx.x%), attaches variable pct. result formatted, first format group, xx, output total width 2 characters, space 2 integers. second format group output total width 7 characters, space 2 integers 1 decimal place. final result, two fields concatenated together, total width string consistently 10 characters. Note though formatting truncate integers, instead total width string expanded, skewing alignment. Decimal points always rounded specified precision.","code":"f_str(\"xx (xx.x%)\", n, pct) #> *** Format String *** #> xx (xx.x%) #> *** vars, extracted formats, and settings *** #> n formated as: xx #> integer length: 2 #> decimal length: 0 #> pct formated as: xx.x #> integer length: 2 #> decimal length: 1 #> Total Format Size: 10"},{"path":"https://atorus-research.github.io/Tplyr/articles/general_string_formatting.html","id":"controlling-formatting","dir":"Articles","previous_headings":"","what":"Controlling Formatting","title":"General String Formatting","text":"Note format string, result numbers formatted fill spaces x’s. characters string preserved . Tplyr’s format strings different valid characters specifically control numeric fields.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/general_string_formatting.html","id":"lowercase-x","dir":"Articles","previous_headings":"Controlling Formatting","what":"Lowercase ‘x’","title":"General String Formatting","text":"detailed first example, using lower case ‘x’, exact width space allotted x’s preserved. Note var1_Placebo row . integer width n counts space right opening parenthesis pct field preserved. guarentees (using monospace font) non-numeric characters within format strings remain place. Given integers don’t truncate, spaces undesired, integers automatically increase width. example , n pct result exceeds 10, width output string automatically expands. can trigger behaivor using single ‘x’ integer side format group.","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE) %>% set_format_strings( f_str(\"xx (xx.x%)\", n, pct) ) ) %>% build() %>% select(1:3) #> # A tibble: 3 × 3 #> row_label1 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 AMERICAN INDIAN OR ALASKA NATIVE \" 0 ( 0.0%)\" \" 1 ( 1.2%)\" #> 2 BLACK OR AFRICAN AMERICAN \" 8 ( 9.3%)\" \" 9 (10.7%)\" #> 3 WHITE \"78 (90.7%)\" \"74 (88.1%)\" tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE) %>% set_format_strings( f_str(\"x (x.x%)\", n, pct) ) ) %>% build() %>% select(1:3) #> # A tibble: 3 × 3 #> row_label1 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 AMERICAN INDIAN OR ALASKA NATIVE 0 (0.0%) 1 (1.2%) #> 2 BLACK OR AFRICAN AMERICAN 8 (9.3%) 9 (10.7%) #> 3 WHITE 78 (90.7%) 74 (88.1%)"},{"path":"https://atorus-research.github.io/Tplyr/articles/general_string_formatting.html","id":"uppercase-x","dir":"Articles","previous_headings":"Controlling Formatting","what":"Uppercase ‘X’","title":"General String Formatting","text":"downside last example alignment format groups completely lost. parenthesis pct field now bound integer percent value, entire string shifted right. Tplyr offers customization using concept called “parenthesis hugging”. triggered using uppercase ‘X’ integer side format group. Consider following example: Now total string width preserved properly. change instead pulling right side format group , essentially aligning left format group, parenthesis moved right towards integer side pct field, “hugging” numeric results percent. two rules using ‘parenthesis hugging’: Capital letters used integer side number character must precede capital letter, otherwise ’s character ‘hug’","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE) %>% set_format_strings( f_str(\"xx (XX.x%)\", n, pct) ) ) %>% build() %>% select(1:3) #> # A tibble: 3 × 3 #> row_label1 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 AMERICAN INDIAN OR ALASKA NATIVE \" 0 (0.0%)\" \" 1 (1.2%)\" #> 2 BLACK OR AFRICAN AMERICAN \" 8 (9.3%)\" \" 9 (10.7%)\" #> 3 WHITE \"78 (90.7%)\" \"74 (88.1%)\""},{"path":"https://atorus-research.github.io/Tplyr/articles/general_string_formatting.html","id":"auto-precision","dir":"Articles","previous_headings":"","what":"Auto-precision","title":"General String Formatting","text":"Lastly, Tplyr also capability automatically determine widths necessary format strings. done using character ‘’ instead ‘x’ format string. Consider following example. Note decimal precision varies different lab test results. feature beneficial decimal precision rules must based precision data collected. information auto-precision descriptive statistics layers, see vignette(\"desc_layer_formatting\"). count layers, auto-precision can also used surrounding n counts. example, default format string counts layers Tplyr set (xxx.x%). auto-format n result based maximum summarized value n within data. example: Given maximum count >=10 <100, integer width n assigned 2. Note auto-precision percents auto-format based available percentages. count filled based n result. layer types, capital follows logic X, triggered using auto-precision. Take example adverse event table: go format group: distinct n count spaced based width maximum n value percent field maximum width 2 characters, opening parenthesis hug integer percent value right event counts within brackets ([]) auto formatted based maximum n value, opening bracket hug n count right. vignette focused specifics formatting using f_str() objects. details layer specifics, check individual layer vignettes.","code":"tplyr_table(tplyr_adlb, TRTA, where=PARAMCD %in% c(\"CA\", \"URATE\")) %>% add_layer( group_desc(AVAL, by=vars(PARAMCD, AVISIT)) %>% set_format_strings( 'Mean (SD)' = f_str('a.a (a.a+1)', mean, sd) ) %>% set_precision_by(PARAMCD) ) %>% build() %>% select(1:5) #> # A tibble: 6 × 5 #> row_label1 row_label2 row_label3 var1_Placebo var1_Xanomeline High Dos…¹ #> #> 1 CA Week 12 Mean (SD) 2.19144 (0.074711) 2.18134 (0.062553) #> 2 CA Week 24 Mean (SD) 2.16838 (0.046617) 2.18063 (0.099174) #> 3 CA Week 8 Mean (SD) 2.19144 (0.102771) 2.23926 (0.199489) #> 4 URATE Week 12 Mean (SD) 298.887 (105.3868) 304.835 ( 85.1772) #> 5 URATE Week 24 Mean (SD) 269.643 (111.8899) 281.539 (126.6612) #> 6 URATE Week 8 Mean (SD) 234.946 ( 45.8806) 273.608 ( 36.6659) #> # ℹ abbreviated name: ¹​`var1_Xanomeline High Dose` tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE) %>% set_format_strings(f_str(\"a (xxx.x%)\", n, pct)) ) %>% build() %>% select(1:3) #> # A tibble: 3 × 3 #> row_label1 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 AMERICAN INDIAN OR ALASKA NATIVE \" 0 ( 0.0%)\" \" 1 ( 1.2%)\" #> 2 BLACK OR AFRICAN AMERICAN \" 8 ( 9.3%)\" \" 9 ( 10.7%)\" #> 3 WHITE \"78 ( 90.7%)\" \"74 ( 88.1%)\" tplyr_table(tplyr_adae, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% add_layer( group_count(AEDECOD) %>% set_format_strings(f_str(\"a (XX.x%) [A]\", distinct_n, distinct_pct, n)) %>% set_distinct_by(USUBJID) ) %>% build() %>% select(1:3) #> # A tibble: 21 × 3 #> row_label1 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 ACTINIC KERATOSIS \" 0 (0.0%) [0]\" \" 1 (1.2%) [1]\" #> 2 ALOPECIA \" 1 (1.2%) [1]\" \" 0 (0.0%) [0]\" #> 3 BLISTER \" 0 (0.0%) [0]\" \" 1 (1.2%) [2]\" #> 4 COLD SWEAT \" 1 (1.2%) [3]\" \" 0 (0.0%) [0]\" #> 5 DERMATITIS ATOPIC \" 1 (1.2%) [1]\" \" 0 (0.0%) [0]\" #> 6 DERMATITIS CONTACT \" 0 (0.0%) [0]\" \" 0 (0.0%) [0]\" #> 7 DRUG ERUPTION \" 1 (1.2%) [1]\" \" 0 (0.0%) [0]\" #> 8 ERYTHEMA \" 9 (10.5%) [13]\" \"14 (16.7%) [22]\" #> 9 HYPERHIDROSIS \" 2 (2.3%) [2]\" \" 8 (9.5%) [10]\" #> 10 PRURITUS \" 8 (9.3%) [11]\" \"26 (31.0%) [38]\" #> # ℹ 11 more rows"},{"path":"https://atorus-research.github.io/Tplyr/articles/layer_templates.html","id":"basic-templates","dir":"Articles","previous_headings":"","what":"Basic Templates","title":"Layer Templates","text":"functions new_layer_template() use_template() allow user create use layer templates. Layer templates allow user pre-build reuse entire layer configuration, layer constructor modifying functions. Furthermore, users can specify parameters may want interchangeable. Additionally, layer templates extensible, template can use extended additional layer modifying functions. Consider following example: example, ’ve created basic layer template. template named “example_template”, name ’ll use reference template want use . template created, start function group_count(...). Note use ellipsis (.e. ...). required part layer template. Templates must start Tplyr layer constructor, one function group_count(), group_desc(), group_shift(). ellipsis necessary template used, able pass arguments directly layer constructor. example: Within use_template(), first parameter template name. , supply arguments normally group_count(), group_desc(), group_shift(). Additionally, note formats applied just used set_format_strings() specified template. template applied, table built settings appropriately. additional feature layer templates act just function Tplyr layer. means ’re also extensible can expanded directly within Tplyr table. example: show two things - first, called template without variable argument previous example. allows template flexibility depending context usage. Furthermore, added additional modifier function add_total_row(). example, took layer constructed template modified layer . may useful layer reusable. reusable portions can put template, rest added using normal Tplyr syntax.","code":"new_layer_template( \"example_template\", group_count(...) %>% set_format_strings(f_str(\"xx (xx%)\", n, pct)) ) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( use_template(\"example_template\", RACE, by=ETHNIC) ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( use_template(\"example_template\", RACE) %>% add_total_row() ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/layer_templates.html","id":"templates-with-parameters","dir":"Articles","previous_headings":"Basic Templates","what":"Templates With Parameters","title":"Layer Templates","text":"’s also possible add interchangeable parameters layer template beyond group constructor arguments. requires special syntax. Consider following template: example, create template similar first example. now add two modifying functions, set_order_count_method() set_ordering_cols(). Within functions, ’ve supplied interchangeable parameters template function, sort_meth sort_col. Tplyr layer template, parameters supplied using curly brackets (.e. {}). specify arguments using templater, use use_template() argument add_params. example: add_params parameter, must supply list. list must also named, element names (example, sort_meth sort_col) match parameter names template . ’s mismatch template’s parameters parameters provided add_params, encounter error. values supplied add_param exactly arguments supply matching field within template (.e. ’s extra quoting using quo() necessary pass symbol).","code":"new_layer_template(\"example_params\", group_count(...) %>% set_format_strings(f_str(\"xx (xx.x%)\", n, pct)) %>% set_order_count_method({sort_meth}) %>% set_ordering_cols({sort_col}) ) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( use_template('example_params', RACE, add_params = list( sort_meth = \"bycount\", sort_col = Placebo )) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/layer_templates.html","id":"viewing-and-removing-templates","dir":"Articles","previous_headings":"","what":"Viewing and Removing Templates","title":"Layer Templates","text":"want view available templates session, use function get_layer_templates(). can view specific template using get_layer_template(). Note layer templates class tplyr_layer_template. additionally carry attribute params specifies parameters available template, can seen output . Finally, want remove layer session, use function remove_layer_template()","code":"get_layer_templates() #> $example_template #> Template name: example_template #> Template parameters: None #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx%)\", n, pct)) #> } #> #> $example_params #> Template name: example_params #> Template parameters: sort_meth, sort_col #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx.x%)\", n, pct)) %>% set_order_count_method({ #> sort_meth #> }) %>% set_ordering_cols({ #> sort_col #> }) #> } get_layer_template(\"example_params\") #> Template name: example_params #> Template parameters: sort_meth, sort_col #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx.x%)\", n, pct)) %>% set_order_count_method({ #> sort_meth #> }) %>% set_ordering_cols({ #> sort_col #> }) #> } remove_layer_template(\"example_params\") get_layer_templates() #> $example_template #> Template name: example_template #> Template parameters: None #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx%)\", n, pct)) #> }"},{"path":"https://atorus-research.github.io/Tplyr/articles/metadata.html","id":"generating-the-metadata","dir":"Articles","previous_headings":"","what":"Generating the Metadata","title":"Tplyr Metadata","text":"Consider following example: trigger creation metadata, build() function new argument metadata. specifying TRUE, underlying metadata within Tplyr prepared extractable format. action user needs specify action take place. metadata argument used, new column produced output dataframe called row_id. row_id variable provides persistent reference row interest, even output dataframe sorted. review vignette(\"styled-table\"), note expect certain amount post processing styling built data frame Tplyr, let use whatever packages prefer. , reference ID necessary.","code":"t <- tplyr_table(tplyr_adsl, TRT01P, where = SAFFL == \"Y\") %>% add_layer( group_count(RACE) ) %>% add_layer( group_desc(AGE, where = EFFFL == \"Y\") ) dat <- t %>% build(metadata=TRUE) kable(dat)"},{"path":"https://atorus-research.github.io/Tplyr/articles/metadata.html","id":"extracting-the-input-source","dir":"Articles","previous_headings":"","what":"Extracting The Input Source","title":"Tplyr Metadata","text":", let’s cut chase. likely way use metadata pull source data created cell. , ’ve provided function get_meta_subset(). information need row_id column name result cell interest. example, looking result , want know 8 subjects Placebo group Black African American: using row_id column, dataframe pulled right us. Notice USUBJID included default, even though Tplyr ’s reference anywhere tplyr_table() variable USUBJID. get_meta_subset() additional argument add_cols allows specify additional columns want included resulting dataframe, default USUBJID. let’s say want additionally include variable SEX. Variables provided using dplyr::vars(), just like cols argument tplyr_table() arguments layer type. mentioned, input source data can extracted result cell created Tplyr. let’s say want know subjects relevant descriptive statistics around age Xanomeline High Dose group: Note: Trimmed space Notice columns returned different. First , within summary , pulled results descriptive statistics layer. target variable layer AGE, AGE returned resulting output. Additionally, layer level argument used subset EFFFL == \"Y\", leads EFFFL included output well.","code":"get_meta_subset(t, 'c2_1', 'var1_Placebo') %>% kable() get_meta_subset(t, 'c2_1', 'var1_Placebo', add_cols = vars(USUBJID, SEX)) %>% kable() get_meta_subset(t, 'd1_2', 'var1_Xanomeline High Dose') %>% head(10) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/metadata.html","id":"extracting-a-result-cells-metadata","dir":"Articles","previous_headings":"","what":"Extracting a Result Cell’s Metadata","title":"Tplyr Metadata","text":"extract dataframe get_meta_subset(), metadata result cell needs first extracted. metadata can directly accessed using function get_meta_result(). Using last example get_meta_subset() : resulting output new object Tplyr called tplyr_meta(). container relevent metadata specific result. object list two elements: names filters. names element contains quosures variable relevant specific result. include target variable, variables used layer, cols variables used table, variables included filter condition relevant create result. filters element contains filter condition (provided calls) necessary create particular cell. include table level argument, layer level argument, filter condition specific value variable cols variable necessary create cell, similarly filter treatment group interest. results provided can unpacked directly dplyr syntax necessary, exactly happens get_meta_subset(). example: Note: Trimmed space - says can’t let imagination run wild?","code":"get_meta_result(t, 'd1_2', 'var1_Xanomeline High Dose') #> tplyr_meta: 4 names, 3 filters #> Names: #> TRT01P, EFFFL, SAFFL, AGE #> Filters: #> TRT01P == c(\"Xanomeline High Dose\"), EFFFL == \"Y\", SAFFL == \"Y\" m <- get_meta_result(t, 'd1_2', 'var1_Xanomeline High Dose') tplyr_adsl %>% filter(!!!m$filters) %>% select(!!!m$names) %>% head(10) %>% kable() cat(c(\"tplyr_adsl %>%\\n\", \" filter(\\n \", paste(purrr::map_chr(m$filters, ~ rlang::as_label(.)), collpase=\",\\n \"), \") %>%\\n\", paste(\" select(\", paste(purrr::map_chr(m$names, rlang::as_label), collapse=\", \"), \")\", sep=\"\") ))"},{"path":"https://atorus-research.github.io/Tplyr/articles/metadata.html","id":"anti-joins","dir":"Articles","previous_headings":"Extracting a Result Cell’s Metadata","what":"Anti Joins","title":"Tplyr Metadata","text":"data presented within table refers back target dataset data summarized. cases, data presented may refer information excluded summary. case use Tplyr function add_missing_subjects_row(). case, counts presented refer data excluded target present population data. metadata thus needs refer excluded data. handle , ’s additional field called ‘Anti Join’. Consider example: missing row example counts subjects within respective treatment groups adverse events body system “SKIN SUBCUTANEOUS TISSUE DISORDERS”. ’s metadata result Placebo treatment group looks like. result addition field ‘Anti-join’. element two fields, join metadata, “” field, specifies merging variable used “anti-joining” target data. join metadata refers data interest population data. Note metadata target data variable names filter conditions referring AEBODSYS AEDECOD, variables present within join metadata, information present within population data. usual joins work focus overlap two sets, anti-join looks non-overlap. metadata provided specifically give us “subjects within Placebo treatment group adverse event within body system ‘SKIN SUBCUTANEOUS TISSUE DISORDERS’”. Extracting metadata works much way extracting results. ’re working tplyr_table object, ’s additional information need provide function.","code":"t <- tplyr_table(tplyr_adae, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) %>% set_distinct_by(USUBJID) %>% add_missing_subjects_row(f_str(\"xx (XX.x%)\", distinct_n, distinct_pct), sort_value = Inf) ) x <- build(t, metadata=TRUE) tail(x) %>% select(starts_with('row'), var1_Placebo) %>% kable() m <- get_meta_result(t, 'c23_1', 'var1_Placebo') m #> tplyr_meta: 3 names, 4 filters #> Names: #> TRTA, AEBODSYS, AEDECOD #> Filters: #> TRTA == c(\"Placebo\"), AEBODSYS == c(\"SKIN AND SUBCUTANEOUS TISSUE DISORDERS\"), TRUE, TRUE #> Anti-join: #> Join Meta: #> tplyr_meta: 1 names, 3 filters #> Names: #> TRT01A #> Filters: #> TRT01A == c(\"Placebo\"), TRUE, TRUE #> On: #> USUBJID head(get_meta_subset(t, 'c23_1', 'var1_Placebo')) #> # A tibble: 6 × 2 #> USUBJID TRT01A #> #> 1 01-701-1015 Placebo #> 2 01-701-1047 Placebo #> 3 01-701-1118 Placebo #> 4 01-701-1153 Placebo #> 5 01-701-1203 Placebo #> 6 01-701-1234 Placebo head(get_meta_subset(t$metadata, 'c23_1', 'var1_Placebo', target=t$target, pop_data=t$pop_data)) #> # A tibble: 6 × 2 #> USUBJID TRT01A #> #> 1 01-701-1015 Placebo #> 2 01-701-1047 Placebo #> 3 01-701-1118 Placebo #> 4 01-701-1153 Placebo #> 5 01-701-1203 Placebo #> 6 01-701-1234 Placebo tplyr_adsl %>% filter( TRTA == c(\"Placebo\") , AEBODSYS == c(\"SKIN AND SUBCUTANEOUS TISSUE DISORDERS\") , TRUE , TRUE , ) %>% select(TRTA, AEBODSYS, AEDECOD)"},{"path":"https://atorus-research.github.io/Tplyr/articles/metadata.html","id":"so-what-does-this-get-me","dir":"Articles","previous_headings":"","what":"So, What Does This Get Me?","title":"Tplyr Metadata","text":"get get metadata around result cell, can get exact results result cell. just need row ID column name. - get ? can query tables - ’s great. use . idea behind really support Shiny. Consider minimal application. Click result cells within table see happens. Source code available ’s . persistent row_id column selection enables use something like Shiny automatically query cell based position table. Using click events package like reactable, can pick row column selected pass information get_meta_result(). get resulting data frame, ’s , world Shiny tip fingers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/options.html","id":"default-layer-formats","dir":"Articles","previous_headings":"","what":"Default Layer Formats","title":"Tplyr Options","text":"Declaring string formats summaries need performed one verbose parts Tplyr. Furthermore, something often fairly consistent within study, ’ll likely want look across consistent set descriptive statistics, count/shift tables likely require sort “n (%)” formatting. Using format options similar setting string format. difference need enter string formats named list instead separate parameters function call. can see Tplyr picks option changes. table , didn’t use set_format_strings() anywhere - instead let Tplyr pick default formats options. One important thing understand options work particular scoping. Tplyr options broadest scope, work across entire session table. Setting formats tplyr_table() level override Tplyr options extends layer specified type current table. Setting formats tplyr_layer() level always prioritized Tplyr options tplyr_table() formats set. narrowest scope always used specified. demonstrate, consider following. Tplyr options remain set block . output: descriptive statistics layer “Age (Years)” uses specified table default using set_desc_layer_formats() first count layer “Categorical Age Groups” uses specified table default using set_count_layer_formats() second count layer “Ethnicity” uses layer level format specified using set_format_strings() outputs ignores Tplyr option defaults.","code":"options( # Count layer defaults tplyr.count_layer_default_formats = list(n_counts = f_str(\"xxx (xx%)\", n, pct), riskdiff = f_str('xx.xxx', dif) ), # Desc layer defaults tplyr.desc_layer_default_formats = list(\"n\" = f_str(\"xxx\", n), \"Mean (SD)\"= f_str(\"a.a+1 (a.a+2)\", mean, sd), \"Median\" = f_str(\"a.a+4\", median) ), # Shift layer defaults tplyr.shift_layer_default_formats = list(f_str(\"xxx\", n)) ) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE, by = \"Age (years)\") ) %>% add_layer( group_count(AGEGR1, by = \"Categorical Age Groups\") ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% set_count_layer_formats(n_counts = f_str(\"xx (xxx%)\", n, pct)) %>% set_desc_layer_formats(\"Mean (SD)\" = f_str(\"a.a+1 (a.a+2)\", mean, sd)) %>% add_layer( group_desc(AGE, by = \"Age (Years)\") ) %>% add_layer( group_count(AGEGR1, by = \"Categorical Age Groups\") ) %>% add_layer( group_count(ETHNIC, by = \"Ethnicity\") %>% set_format_strings(f_str(\"xxxxx (xx.xxx%)\", n, pct)) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/options.html","id":"precision-cap","dir":"Articles","previous_headings":"","what":"Precision Cap","title":"Tplyr Options","text":"Tplyr defaults avoiding capping precision. capping precision conscious decision, user specifically set limit many decimal places relevant specific result. One way cap precision using cap parameter within set_format_strings(). perhaps specific limit ’d like see output. , offer tplyr.precision_cap option set whatever cap wish. Similar layer defaults, setting precision cap layer level override tplyr.precision_cap option. layers example summarizing data. top layer using tplyr.precision_cap option set , limits 2 integer place 2 decimal places. bottom layer applies cap override option. Recall things auto precision: Integers truncated - rather, auto precision default much padding applied. number exceeds number spaces, length extended (.e. 2 integer places allotted, 100 still consume 3 places). cap applies spaces allotted ‘’. cap 2, ‘+1’ exceed 3 spaces. bottom layer overrides Tplyr option. Instead, integers capped 1 space, decimals capped 0.","code":"options(tplyr.precision_cap = c('int'=2, 'dec'=2)) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(HEIGHTBL, by = \"Height at Baseline\") %>% set_format_strings( 'Mean (SD)' = f_str('a.a (a.a+1)', mean, sd) ) ) %>% add_layer( group_desc(HEIGHTBL, by = \"Height at Baseline (Limited)\") %>% set_format_strings( 'Mean (SD)' = f_str('a.a (a.a+1)', mean, sd), cap = c('int'= 1, 'dec'=0) ) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/options.html","id":"custom-summaries","dir":"Articles","previous_headings":"","what":"Custom Summaries","title":"Tplyr Options","text":"Custom summaries allow extend capabilities descriptive statistics layers Tplyr. Maybe defaults don’t work ’d like , maybe custom functions within organization commonly like use. Specifying custom summaries wish use every table prove quite tedious - therefore, tplyr.custom_summaries option better choice. Note table code used produce output . Now Tplyr used custom summary function geometric_mean specified tplyr.custom_summaries option. Also note use rlang::quos(). ’ve done best mask user everywhere possible make interfaces clean intuitive, great deal Tplyr built using ‘rlang’ non-standard evaluation. Within option one instances user needs concern use quosures. ’d like learn non-standard evaluation quosures, recommend Section IV Advanced R. Now geometric mean set within Tplyr options, can use within descriptive statistics layers, just like one built-summaries.","code":"options(tplyr.custom_summaries = rlang::quos( geometric_mean = exp(sum(log(.var[.var > 0]),na.rm=TRUE) / length(.var)) )) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE) %>% set_format_strings('Geometric Mean' = f_str('xx.xx', geometric_mean)) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/options.html","id":"scientific-notation","dir":"Articles","previous_headings":"","what":"Scientific Notation","title":"Tplyr Options","text":"default, R switch scientific notation number less .001. controlled scipen option. default value scipen 0. ’d like increase decimal places required scientific notation triggered, increase value scipen. value scipen number orders ten smaller (.e. decimal places preceded 0’s) required switch scientific notation. Decreasing value scipen cause R switch scientific location larger numbers. easier understand example. Tplyr, option tplyr.scipen. scipen setting used Tplyr table built. allows use different scipen setting within Tplyr R session. default value use Tplyr 9999, intended totally prevent numbers switching scientific notation. want conscious decision make order prevent unexpected outputs. Note risk-difference variables mostly shifted scientific notation. limit shifted .1 within Tplyr build.","code":"options(scipen = 0) # This is the default .0001 #> [1] 1e-04 options(scipen = 1) # Require 5 decimal places instead .0001 #> [1] 0.0001 .00001 #> [1] 1e-05 options(scipen = -1) # Only require 3 decimal places .001 #> [1] 1e-03 options(tplyr.scipen = -3) t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% add_risk_diff(c('Xanomeline Low Dose', 'Placebo')) ) suppressWarnings(build(t)) %>% # Chi-squared warnings occur with small samples head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/options.html","id":"quantile-algorithms","dir":"Articles","previous_headings":"","what":"Quantile Algorithms","title":"Tplyr Options","text":"many algorithms available compute quantile R 9, controlled type parameter quantile(). descriptive statistics offer built-summaries Q1, Q3, Interquartile range, three use quantile() underlying implementation. Given offer default, felt important offer flexibility change algorithm. can tplyr.quantile_type. default chose use R default Type 7: \\[ m = 1-p. p[k] = (k - 1) / (n - 1). \\textrm{case, } p[k] = mode[F(x[k])]. \\textrm{used S.} \\] example demonstrates using default quantile algorithm R Within clinical world, may wish match way SAS calculates quantiles. match SAS’s definition, use Type 3: \\[ \\textrm{Nearest even order statistic. γ = 0 g = 0 j even, 1 otherwise.} \\]","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(CUMDOSE) %>% set_format_strings(\"Q1, Q3\" = f_str('xxxxx, xxxxx', q1, q3)) ) %>% build() %>% kable() options(tplyr.quantile_type = 3) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(CUMDOSE) %>% set_format_strings(\"Q1, Q3\" = f_str('xxxxx, xxxxx', q1, q3)) ) %>% build() %>% select(-starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/options.html","id":"ibm-rounding","dir":"Articles","previous_headings":"","what":"IBM Rounding","title":"Tplyr Options","text":"certain cases users may want match tables produced languages IBM rounding.Tplyr offers option ‘tplyr.IBMRounding’ change default rounding behavior Tplyr tables. Review var1_4 tables . Using default R behavior Using IBM rounding","code":"tplyr_table(mtcars, gear) %>% add_layer( group_desc(qsec) %>% set_format_strings(mean = f_str(\"xx.xx\", mean)) ) %>% build() #> # A tibble: 1 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 mean 17.69 18.96 15.64 1 1 withr::with_options( list(tplyr.IBMRounding = TRUE), { tplyr_table(mtcars, gear) %>% add_layer( group_desc(qsec) %>% set_format_strings(mean = f_str(\"xx.xx\", mean)) ) %>% build() } ) #> Warning: You have enabled IBM Rounding. This is an experimental feature. #> • If you have feedback please get in touch with the maintainers! #> This warning is displayed once every 8 hours. #> # A tibble: 1 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 mean 17.69 18.97 15.64 1 1"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"string-wrapping","dir":"Articles","previous_headings":"","what":"String wrapping","title":"Post-Processing","text":"Certain types output formats don’t elegantly handle string wrapping text. formats, simply width text word wraps. formats, LaTex outputs PDF (depending rendering engine) may wrap white space fine, words whose character length longer allotted width may print wider table cell. address , Tplyr ’ve added function str_indent_wrap(). largely built top function stringr::str_wrap() preserve much efficiency possible, two issues common clinical outputs addressed: Preceding indentation word preserved. example, nested adverse event table, preferred term indented, function wrap preserve words indentation new line. Words exceed specified width wrapped hyphenation. post-processing function, note function works tibble data.frame object, Tplyr table. Let’s look example. Note: ’re viewing data frame output HTML based outputs eliminate duplicate white spaces, makes difficult see things like padded indentation","code":"dat <- tibble( row_label1 = c(\"RENAL AND URINARY DISORDERS\", \" NEPHROLITHIASIS\"), var1_Placebo = c(\" 5 (50.0%)\", \" 3 (30.0%)\") ) dat %>% mutate( row_label1 = str_indent_wrap(row_label1, width = 10) ) #> # A tibble: 2 × 2 #> row_label1 var1_Placebo #> #> 1 \"RENAL AND\\nURINARY\\nDISORDERS\" \" 5 (50.0%)\" #> 2 \" NEPHROLIT-\\n HIASIS\" \" 3 (30.0%)\""},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"row-masking","dir":"Articles","previous_headings":"","what":"Row Masking","title":"Post-Processing","text":"Row masking process blanking repeat row values within data frame give appearance grouping variables. table packages, gt, handle . packages, like huxtable, options like merging cells, may simplistic approach. Furthermore, common approach clinical tables data validation done output dataframe. example, note “Race n (%)” duplicated row. can blank using `apply_row_masks() second feature apply_row_masks() ability apply row breaks different groups data, example, different layers table. row breaks inserted blank rows. Additionally, row breaks inserted ’ll additional variable ord_break added dataframe, value 1 table data rows 2 newly added break rows. Character variables blank values (.e. \"\") numeric sorting values NA. considerations using apply_row_masks(): function order dependent, make sure data sorted submitting apply_row_masks() inserting row breaks, default Tpylr variable ord_layer_index used. can submit variables via ellipsis parameter (...) ’d like use different variable grouping insert rows","code":"dat <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE, by = \"Race n (%)\") ) %>% build() %>% select(1:3) kable(dat) dat %>% apply_row_masks() %>% kable() dat <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE, by = \"Race n (%)\") ) %>% add_layer( group_desc(AGE, by = \"Age (years)\") ) %>% build() dat %>% apply_row_masks(row_breaks=TRUE) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"collapsing-row-labels","dir":"Articles","previous_headings":"","what":"Collapsing Row Labels","title":"Post-Processing","text":"Different table formats call different handling row labels, depending preferences individual organization specifics table hand. Tplyr inherently creates row labels separate columns, similar way count layers nest inner outer layer, also offer collapse_row_labels() function pull multiple row labels single column. default, indentation set 2 spaces, using indent parameter can change string desire. also control columns collapse, allowing keep separate row labels don’t want collapsed together","code":"dat <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE, by = vars(\"Race n (%)\", SEX)) ) %>% add_layer( group_desc(AGE, by = vars(\"Age (years)\", SEX)) ) %>% build() collapse_row_labels(dat, row_label1, row_label2, row_label3) %>% select(row_label, var1_Placebo) #> # A tibble: 26 × 2 #> row_label var1_Placebo #> #> 1 \"Race n (%)\" \"\" #> 2 \" F\" \"\" #> 3 \" AMERICAN INDIAN OR ALASKA NATIVE\" \" 0 ( 0.0%)\" #> 4 \" BLACK OR AFRICAN AMERICAN\" \" 5 ( 5.8%)\" #> 5 \" WHITE\" \"48 ( 55.8%)\" #> 6 \"Race n (%)\" \"\" #> 7 \" M\" \"\" #> 8 \" AMERICAN INDIAN OR ALASKA NATIVE\" \" 0 ( 0.0%)\" #> 9 \" BLACK OR AFRICAN AMERICAN\" \" 3 ( 3.5%)\" #> 10 \" WHITE\" \"30 ( 34.9%)\" #> # ℹ 16 more rows collapse_row_labels(dat, row_label1, row_label2, row_label3, indent = \"  \") %>% select(row_label, var1_Placebo) %>% kable(escape=FALSE) collapse_row_labels(dat, row_label1, row_label2, indent = \"  \") %>% select(row_label, row_label3, var1_Placebo) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"leading-spaces-in-html-files","dir":"Articles","previous_headings":"","what":"Leading Spaces in HTML Files","title":"Post-Processing","text":"Another helper function ’ve made available replace_leading_whitespace(). table created , note indent parameter set using  , non-breaking space. can used HTML files preserve leading white spaces instead automatically stripping display, viewing utilities usually . Ever noticed data viewers typically don’t see leading spaces? Yeah - ’s ! Let’s take example change indent parameter. indented rows, spaces still exist, can see dataframe output . HTML view strips pass kable() function. replace_leading_whitespace() take care us converting spaces. Note ’ll see   raw data . now want use display,   characters show leading whitespace within HTML table. Note ’ll need prevent escaping special characters work, raw text display. kable() can use escape=FALSE .","code":"collapse_row_labels(dat, row_label1, row_label2) %>% select(row_label, row_label3, var1_Placebo) %>% kable() collapse_row_labels(dat, row_label1, row_label2) %>% select(row_label, row_label3, var1_Placebo) %>% head() #> # A tibble: 6 × 3 #> row_label row_label3 var1_Placebo #> #> 1 \"Race n (%)\" \"\" \"\" #> 2 \" F\" \"AMERICAN INDIAN OR ALASKA NATIVE\" \" 0 ( 0.0%)\" #> 3 \" F\" \"BLACK OR AFRICAN AMERICAN\" \" 5 ( 5.8%)\" #> 4 \" F\" \"WHITE\" \"48 ( 55.8%)\" #> 5 \" M\" \"AMERICAN INDIAN OR ALASKA NATIVE\" \" 0 ( 0.0%)\" #> 6 \" M\" \"BLACK OR AFRICAN AMERICAN\" \" 3 ( 3.5%)\" collapse_row_labels(dat, row_label1, row_label2) %>% select(row_label, row_label3, var1_Placebo) %>% mutate( across(where(is.character), ~ replace_leading_whitespace(.)) ) %>% head() #> # A tibble: 6 × 3 #> row_label row_label3 var1_Placebo #> #> 1 Race n (%) \"\" \"\" #> 2   F \"AMERICAN INDIAN OR ALASKA NATIVE\" \" 0 ( 0.0%)\" #> 3   F \"BLACK OR AFRICAN AMERICAN\" \" 5 ( 5.8%)\" #> 4   F \"WHITE\" \"48 ( 55.8%)\" #> 5   M \"AMERICAN INDIAN OR ALASKA NATIVE\" \" 0 ( 0.0%)\" #> 6   M \"BLACK OR AFRICAN AMERICAN\" \" 3 ( 3.5%)\" collapse_row_labels(dat, row_label1, row_label2) %>% select(row_label, row_label3, var1_Placebo) %>% mutate( across(where(is.character), ~ replace_leading_whitespace(.)) ) %>% head() %>% kable(escape=FALSE)"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"conditional-formatting","dir":"Articles","previous_headings":"","what":"Conditional Formatting","title":"Post-Processing","text":"circumstances, like add_total_row(), Tplyr lets specify special formats separate set_format_strings(). within table body ’s way set specific, conditional formats based table data . address , ’ve added post-processing function apply_conditional_format() allow set conditional formats result cells. apply_conditional_format() operates character vector, can generally used within context dplyr::mutate() like character modifying function. make 1:1 replacement values, return character vector equal length. Let’s look two examples. two examples achieve result, work slightly differently. Let’s walk throug syntax: first parameter input character vector second parameter refers format group. format group index number within result cell ’d like target. result 8 (9.3%), two format groups. value first 8. value second 9.3. controls number ’ll use establish condition. third parameter condition evaluate establish conditional format applied. , use variable name x, takes value chosen format group. condition filter condition, must return boolean vector TRUE/FALSE. fourth parameter string value used replacement. Finally, last parameter full_string, difference first second examples. apply_conditional_format() can two types replacements. first example full string replacement. case, whatever value provide replacement used verbatim condition evaluates TRUE. set false, format group specified replaced. context, let’s look third example. example target percent field using format group 2, now replacement text (<1%). full_string uses default value FALSE, format group specified replaced. apply_conditional_format() establishes width format group targeted, replacement text right align within targetted portion string ensure alignment string preserved. example within Tplyr result dataframe, let’s look example dataset earlier. Let’s say n (%) values within first count layer conditional format. Using fancy dplyr code, apply_conditional_format(), can make happen. syntax gets bit complicated, using dplyr::across() can apply function across result variables, variable names start var. function using purrr style anonymous function simplicity. couple ways can R. Referencing documentation purrr::map(): formula, e.g. ~ . + 1. must use . refer first argument. recommended require backward compatibility older versions R. anonymous function, e.g. \\(x) x + 1 function(x) x + 1. Within function, ’re additionally using if_else() apply function first layer using ord_layer_index variable. together, ’re effectively running apply_conditional_formats() function first layer, running across variables start var.","code":"string <- c(\" 0 (0.0%)\", \" 8 (9.3%)\", \"78 (90.7%)\") apply_conditional_format(string, 2, x == 0, \" 0 \", full_string=TRUE) #> [1] \" 0 \" \" 8 (9.3%)\" \"78 (90.7%)\" apply_conditional_format(string, 2, x == 0, \"\") #> [1] \" 0 \" \" 8 (9.3%)\" \"78 (90.7%)\" apply_conditional_format(string, 2, x < 1, \"(<1%)\") #> [1] \" 0 (<1%)\" \" 8 (9.3%)\" \"78 (90.7%)\" dat_new <- dat %>% mutate( across(starts_with('var'), # Apply to variables that start with `var` ~ if_else( ord_layer_index == 1, # Target the count layer apply_conditional_format( string = ., # This is dplyr::across syntax format_group = 2, # The percent field condition = x == 0, # Our condition replacement = \"\" # Replacement value ), . ) ) ) kable(dat_new)"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"extracting-a-format-group","dir":"Articles","previous_headings":"","what":"Extracting a Format Group","title":"Post-Processing","text":"Tplyr outputs result, using set_format_strings() f_str() result concatenated together within single result cell. example, within count layer Tplyr table, ’s way directly output n pct values separate columns. result want, post-processing step can use function str_extract_fmt_group(). str_extract_fmt_group() allows reach within result string extract individual format group. Consider example: first call str_extract_fmt_group(), target n counts. first format group string extracted, preserving allotted width portion string. Similarly, second group extract percent counts, including surround parentheses. practice, str_extract_fmt_group() can used separate format groups columns. sake display, output select Placebo column, note able dynamically separate n results pct results. cases, functions tidyr::separate() also used get result like , str_extract_fmt_group() specifically targets expected formatting format groups, without craft specific expression may get confused things like spaces unexpected places.","code":"string <- c(\" 5 (5.8%)\", \" 8 (9.3%)\", \"78 (90.7%)\") # Get the n counts str_extract_fmt_group(string, 1) #> [1] \" 5\" \" 8\" \"78\" # Get the pct counts str_extract_fmt_group(string, 2) #> [1] \"(5.8%)\" \"(9.3%)\" \"(90.7%)\" dat <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE) ) %>% build() dat %>% mutate( across(starts_with('var'), ~ str_extract_fmt_group(., 1), .names = \"{.col}_n\"), across(starts_with('var'), ~ str_extract_fmt_group(., 2), .names = \"{.col}_pct\") ) %>% select(row_label1, var1_Placebo_n, var1_Placebo_pct) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"highly-customized-sort-variables","dir":"Articles","previous_headings":"","what":"Highly Customized Sort Variables","title":"Post-Processing","text":"much vein str_extract_fmt_group(), function str_extract_num() allows target format group extract number within. can used circumstance may want pull number result cell, probably best example highly specific sort sequence. Consider adverse event table. vignette(\"sort\") go circumstances may want sort descending occurrence result. ’ve received questions establish tie breakers scenario, ties broken sorting descending occurrence adverse event within high dose group, low dose group, finally placebo group. Tplyr doesn’t allow output order variables default, getting numbers quite simple str_extract_num(). Let’s consider simplified scenario Given data, let’s say want sort descending occurrence event, using number subjects. first format group. want sort using high dose, low dose, placebo. Let’s create order variables. Now effectively additional order variables necessary sort sequence desired.","code":"dat <- tplyr_table(tplyr_adae, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% add_layer( group_count(AEDECOD) %>% set_format_strings(f_str(\"xx (XX.x%) [A]\", distinct_n, distinct_pct, n)) %>% set_distinct_by(USUBJID) ) %>% build() dat %>% head() %>% kable() dat_ord <- dat %>% mutate( across(starts_with('var1'), ~str_extract_num(., 1), .names = \"{.col}_ord\") ) dat_ord %>% head() %>% select(row_label1, matches('^var.*ord$')) #> # A tibble: 6 × 4 #> row_label1 var1_Placebo_ord var1_Xanomeline High…¹ var1_Xanomeline Low …² #> #> 1 ACTINIC KERATO… 0 1 0 #> 2 ALOPECIA 1 0 0 #> 3 BLISTER 0 1 5 #> 4 COLD SWEAT 1 0 0 #> 5 DERMATITIS ATO… 1 0 0 #> 6 DERMATITIS CON… 0 0 1 #> # ℹ abbreviated names: ¹​`var1_Xanomeline High Dose_ord`, #> # ²​`var1_Xanomeline Low Dose_ord`"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"external-data-formatting","dir":"Articles","previous_headings":"","what":"External Data Formatting","title":"Post-Processing","text":"last post processing function worth mentioning isn’t necessarily meant post-processing data Tplyr . understand Tplyr can’t produce every single summary ’d need clinical trial - never intended able . built Tplyr try work effectively packages tools. Tplyr’s string formatting tools work quite well, ’ve externalized capability using function apply_formats(). basic example, let’s look mtcars data. able leverage string formatting available f_str(), apply generically another data frame within dplyr::mutate(). allows format data, outside Tplyr, still bring quality life Tplyr offer.","code":"mtcars %>% mutate( new_column = apply_formats(\"xx (xx.x)\", gear, mpg) ) %>% select(gear, mpg, new_column) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/riskdiff.html","id":"tplyr-implementation","dir":"Articles","previous_headings":"","what":"Tplyr Implementation","title":"Risk Difference","text":"current implementation risk difference solely built top base R function stats::prop.test(). questions method, please review stats::prop.test() documentation within R. Risk difference built top count layers, ’s comparison proportions. add risk difference calculation count layer, simply use function add_risk_diff(). made large effort make flow naturally count layer construction, let’s walk step step. Comparisons specified two-element character vectors. simply comparison group - first element, reference group - second. coincides might see risk difference specified header mock, ’ll see something like T1-Placebo. can provide many comparisons want - values specified comparison just need valid treatment groups within data. works treatment group built using add_treat_grps() add_total_group() well. risk difference calculations displayed rdiff columns. rdiff column every comparison made, following convention rdiff__. Note use base::suppressWarnings() - counts used stats::prop.test() low, ’ll get warning says “Chi-squared approximation may incorrect” every time stats::prop.test() run counts low… happen lot, warning perfectly valid.","code":"t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo') ) ) suppressWarnings(build(t)) %>% head() %>% select(starts_with(\"rdiff\"), everything()) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/riskdiff.html","id":"controlling-presentation","dir":"Articles","previous_headings":"","what":"Controlling Presentation","title":"Risk Difference","text":"default values presented within formatted strings built table : difference 95% confidence interval low 95% confidence interval high good bit control values though, can controlled way format count summaries - using set_format_strings(). Take look rdiff columns now - ’ll see 5 values. : comparison proportion (.e. estimate[1] output stats::prop.test() object) reference proportion (.e. estimate[2] output stats::prop.test() object) difference (.e. estimate[1] - estimate[2]) lower end confidence interval upper end confidence interval control formatting display values count summaries. Taking things step , can also pass forward arguments stats::prop.test() using named list args argument add_risk_diff(). wasn’t done using ellipsis (.e. ...) like typical R functions ’s already used capture varying number comparisons, ’s much difficult use: seen , using args argument, : Changed confidence interval level 90% instead default 95% Switched alternative hypothesis stats::prop.test() “less” instead default “two.sided” Turned Yates’ continuity correction information parameters, see documentation stats::prop.test().","code":"t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo') ) %>% set_format_strings( 'n_counts' = f_str('xx (xx.x) [x]', distinct_n, distinct_pct, n), 'riskdiff' = f_str('xx.xxx, xx.xxx, xx.xxx, xx.xxx, xx.xxx', comp, ref, dif, low, high) ) ) suppressWarnings(build(t)) %>% head() %>% select(starts_with(\"rdiff\"), everything()) %>% kable() t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo'), args = list(conf.level=0.90, alternative='less', correct=FALSE) ) %>% set_format_strings( 'n_counts' = f_str('xx (xx.x) [x]', distinct_n, distinct_pct, n), 'riskdiff' = f_str('xx.xxx, xx.xxx, xx.xxx, xx.xxx, xx.xxx', comp, ref, dif, low, high) ) ) suppressWarnings(build(t)) %>% head() %>% select(starts_with(\"rdiff\"), everything()) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/riskdiff.html","id":"other-notes","dir":"Articles","previous_headings":"","what":"Other Notes","title":"Risk Difference","text":"default add_risk_diff() works distinct counts available within count summary. whatever reason ’d like run risk difference non-distinct counts, switch distinct argument FALSE. add_risk_diff() also function multi-level summaries different single level, concerns either. Risk difference also works cols argument, ’s important understand comparisons work situation. , ’s still treatment groups compared - column argument used “” variable. example:","code":"t <- tplyr_table(tplyr_adae, TRTA, where= AEBODSYS == \"SKIN AND SUBCUTANEOUS TISSUE DISORDERS\") %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% set_pop_where(TRUE) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo') ) ) suppressWarnings(build(t)) %>% head() %>% select(starts_with(\"rdiff\"), everything()) %>% kable() t <- tplyr_table(tplyr_adae, TRTA, where= AEBODSYS == \"SKIN AND SUBCUTANEOUS TISSUE DISORDERS\") %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo'), distinct=FALSE ) ) suppressWarnings(build(t)) %>% head() %>% select(starts_with(\"rdiff\"), everything()) %>% kable() t <- tplyr_table(tplyr_adae, TRTA, where= AEBODSYS == \"SKIN AND SUBCUTANEOUS TISSUE DISORDERS\", cols=SEX) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo') ) ) suppressWarnings(build(t)) %>% head() %>% select(starts_with(\"rdiff\"), starts_with(\"row\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/riskdiff.html","id":"getting-raw-numbers","dir":"Articles","previous_headings":"","what":"Getting Raw Numbers","title":"Risk Difference","text":"Just like can get numeric data Tplyr layer get_numeric_data(), ’ve also opened door extract raw numeric data risk difference calculations well. done using function get_stats_data(). function interface almost identical get_numeric_data(), except extra parameter statistic. Although risk difference statistic implemented Tplyr moment (outside descriptive statistics), understand multiple methods calculate risk difference, ’ve built risk difference way expanded easily add new methods future. therefore, get_stats_data() statistic parameter allow differentiate situation multiple statistical methods applied layer. output get_stats_data() depends parameters used: specific layer entered layer parameter, element returned layer statistic entered statistic parameter, element returned statistic layer neither statistic layer entered, list lists returned, outer list layer inside list numeric statistic data layer. works best layers named, makes output much clearer. Instead playing around lists, get_stats_data() advantageous ’d like extract data specifically. Let’s say ’d like see just difference values Preferred Term layer table . Using data frame, access un-formatted numeric values rounding formatting. gives flexibility use calculations contexts, make precise comparisons double programming scenario, take deeper look calculations made values result warrant investigation.","code":"t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer(name=\"PreferredTerm\", group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo') ) ) %>% add_layer(name=\"BodySystem\", group_count(AEBODSYS) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo') ) ) suppressWarnings( get_stats_data(t) ) #> $PreferredTerm #> $PreferredTerm$riskdiff #> # A tibble: 105 × 4 #> summary_var measure Xanomeline High Dose_Place…¹ Xanomeline Low Dose_…² #> #> 1 ACTINIC KERATOSIS comp 0.0238 0 #> 2 ACTINIC KERATOSIS ref 0 0 #> 3 ACTINIC KERATOSIS dif 0.0238 0 #> 4 ACTINIC KERATOSIS low -0.0461 0 #> 5 ACTINIC KERATOSIS high 0.0937 0 #> 6 ALOPECIA comp 0 0 #> 7 ALOPECIA ref 0.0476 0.0476 #> 8 ALOPECIA dif -0.0476 -0.0476 #> 9 ALOPECIA low -0.174 -0.174 #> 10 ALOPECIA high 0.0792 0.0792 #> # ℹ 95 more rows #> # ℹ abbreviated names: ¹​`Xanomeline High Dose_Placebo`, #> # ²​`Xanomeline Low Dose_Placebo` #> #> #> $BodySystem #> $BodySystem$riskdiff #> # A tibble: 5 × 4 #> summary_var measure Xanomeline High Dose…¹ Xanomeline Low Dose_…² #> #> 1 SKIN AND SUBCUTANEOUS T… comp 1 1 #> 2 SKIN AND SUBCUTANEOUS T… ref 1 1 #> 3 SKIN AND SUBCUTANEOUS T… dif 0 0 #> 4 SKIN AND SUBCUTANEOUS T… low 0 0 #> 5 SKIN AND SUBCUTANEOUS T… high 0 0 #> # ℹ abbreviated names: ¹​`Xanomeline High Dose_Placebo`, #> # ²​`Xanomeline Low Dose_Placebo` suppressWarnings( get_stats_data(t, layer='PreferredTerm', statistic='riskdiff', where= measure == \"dif\") ) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/shift.html","id":"a-basic-example","dir":"Articles","previous_headings":"","what":"A Basic Example","title":"Shift Layers","text":"Let’s look example. First, let’s look differences shift API. Shift layers must take row column variable, layer designed create box explains changes state. row variable typically “” variable, column variable typically “” variable. Behind scenes, Tplyr breaks properly count present data. part, last example gets us want go - ’s still ’s left desired. doesn’t look like ‘L’ values BNRIND dataset getting rows containing ‘L’. Let’s see can fix dummying possible values.","code":"tplyr_table(tplyr_adlb, TRTA, where=PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, VISIT)) ) %>% build() %>% head(20) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/shift.html","id":"filling-missing-groups-using-factors","dir":"Articles","previous_headings":"","what":"Filling Missing Groups Using Factors","title":"Shift Layers","text":"go. another situation using factors R let’s us dummy values within dataset. Furthermore, since factors ordered, automatically corrected sort order row labels .","code":"tplyr_adlb$ANRIND <- factor(tplyr_adlb$ANRIND, levels=c(\"L\", \"N\", \"H\")) tplyr_adlb$BNRIND <- factor(tplyr_adlb$BNRIND, levels=c(\"L\", \"N\", \"H\")) tplyr_table(tplyr_adlb, TRTA, where=PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, VISIT)) ) %>% build() %>% head(20) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/shift.html","id":"where-to-go-from-here","dir":"Articles","previous_headings":"","what":"Where to go from here","title":"Shift Layers","text":"’s much learn! Check sorting vignette information sorting. Additionally, check vignette denominators understand controlling nuance shift tables.","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"ordering-helpers","dir":"Articles","previous_headings":"Sorting Table Columns","what":"Ordering Helpers","title":"Sorting a Tplyr Table","text":"Ordering helpers columns added Tplyr tables make sure can sort display preference. general, Tplyr create: One order variable order layers One order variable variable least one order variable target variables example , t table outputs three columns: ord_layer_index indexes layer . ord_layer_1 indexes first variable, SEX. options presented sorting done alphabetically. ord_layer_2 indexes values EOSSTT variable count layer, names summaries desc layer.","code":"t %>% select(starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"reordering-and-dropping-columns","dir":"Articles","previous_headings":"Sorting Table Columns","what":"Reordering and Dropping Columns","title":"Sorting a Tplyr Table","text":"Column selection data frames something already well done R. functions dplyr::select(), magrittr::extract(), [ can used reorder drop column cleanly concisely based user’s preference. drop ordering helpers, can easily subtract ‘dplyr’ ‘tidyselect’. can reorder columns. example “Total” result column moved front results. information, ’s well worth time familiarize select helpers work ‘dplyr’.","code":"t %>% select(-starts_with(\"ord_\")) %>% kable() t %>% select( starts_with(\"row\"), var1_Total, starts_with(\"var1\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"sorting-the-layers","dir":"Articles","previous_headings":"","what":"Sorting the Layers","title":"Sorting a Tplyr Table","text":"Layers one fundamental building blocks Tplyr. layer executes independently, end build ’re bound together. ord_layer_index variable allows differentiate sort layers table built. Layers indexed order added table using add_layer() add_layers(). example, let’s say wanted reverse order layers.","code":"t %>% select(starts_with(\"row\"), starts_with(\"ord\")) %>% arrange(desc(ord_layer_index)) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"sorting-the-by-variables","dir":"Articles","previous_headings":"","what":"Sorting the by Variables","title":"Sorting a Tplyr Table","text":"variable gets order column well. named ord_layer_ typically relates back row_label variable (isn’t necessarily case count layers nested - see vignette(\"count\")). order variables calculate based first applicable method . variable factor, values ordering column associated factor levels. variable VARN variable target dataset, (.e. AVISIT AVISITN, PARAM PARAMN), variable extracted used ordering variable associated row label. neither 1 2 true, values ordering column based alphabetical sorting. resulting column numeric.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"factor","dir":"Articles","previous_headings":"Sorting the by Variables","what":"Factor","title":"Sorting a Tplyr Table","text":"’s VARN variable target dataset, Tplyr check variable provided factor. ’re new R, spending time trying understand factor variables quite worthwhile. Let’s look example using variable ETHNIC see advantages practice. Factor variables ‘levels’. levels essentially VARN variables trying achieve - specify order different values within associated variable. variable set specifies “HISPANIC LATINO” sort first, “HISPANIC LATINO”, finally “DUMMY”. Notice ’re alphabetical? highly advantageous aspect using factor variables Tplyr factor variables can used insert dummy values table. Consider line code : converting variable ETHNIC factor, setting factor levels. doesn’t change values dataset - values “dummy” within ETHNIC ADSL. Yet output built , see rows “DUMMY”. using factors, can insert rows Tplyr table don’t exist data. particularly helpful ’re working data early study, certain values expected, yet currently exist data. help prepare tables complete even data .","code":"tplyr_adsl$ETHNIC <- factor(tplyr_adsl$ETHNIC, levels=c(\"HISPANIC OR LATINO\", \"NOT HISPANIC OR LATINO\", \"DUMMMY\")) tplyr_table(tplyr_adsl, TRT01A) %>% add_layer( group_count(EOSSTT, by = ETHNIC) ) %>% build() %>% select(row_label1, row_label2, ord_layer_1) %>% kable() tplyr_adsl$ETHNIC <- factor(tplyr_adsl$ETHNIC, levels=c(\"HISPANIC OR LATINO\", \"NOT HISPANIC OR LATINO\", \"DUMMMY\"))"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"varn","dir":"Articles","previous_headings":"Sorting the by Variables","what":"VARN","title":"Sorting a Tplyr Table","text":"demonstrate use VARN sorting, consider variable RACE. ADSL, RACE also RACEN: Tplyr automatically figure , pull RACEN values variable ord_layer_1.","code":"tplyr_adsl %>% distinct(RACEN, RACE) %>% kable() tplyr_table(tplyr_adsl, TRT01A) %>% add_layer( group_count(EOSSTT, by = RACE) ) %>% build() %>% select(row_label1, row_label2, ord_layer_1) %>% arrange(ord_layer_1) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"alphabetical","dir":"Articles","previous_headings":"Sorting the by Variables","what":"Alphabetical","title":"Sorting a Tplyr Table","text":"Lastly, target doesn’t VARN variable target dataset isn’t factor,Tplyr sort variable alphabetically. resulting order variable numeric, simply numbering variable values alphabetically. Nothing fancy !","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"sorting-descriptive-statistic-summaries","dir":"Articles","previous_headings":"","what":"Sorting Descriptive Statistic Summaries","title":"Sorting a Tplyr Table","text":"variables, layer sort results slightly differently. ’ll start simple case - descriptive statistic layers. user, full control order results present using set_format_strings(). Results ordered based order create f_str() objects. separate “Groups” added indexed based position set_format_strings(). ’d like change order, need update set_format_strings() call.","code":"tplyr_table(tplyr_adsl, TRT01A) %>% add_layer( group_desc(HEIGHTBL) %>% set_format_strings( 'Group 1' = f_str('xx.x', mean), 'Group 2' = f_str('xx.x', median), 'Group 3' = f_str('xx.x', sd) ) ) %>% build() %>% select(starts_with(\"row\"), starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"sorting-count-layers","dir":"Articles","previous_headings":"","what":"Sorting Count Layers","title":"Sorting a Tplyr Table","text":"order results appear frequency table can deceptively complex depends situation hand. mind, Tplyr 3 different methods ordering results count layer using function set_order_count_method(): “byfactor” - default method sort factor. input variable factor, alphabetical sorting used. “byvarn” - Similar ‘’ variable, count target can sorted VARN variable existing target dataset. “bycount” - complex method. Many tables require counts sorted based counts within particular group, like treatment variable. Tplyr can populate ordering column based numeric values within results column. requires granular control, ’ve created functions set_ordering_cols() set_result_order_var() specify column numeric value ordering column based.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"byfactor-and-byvarn","dir":"Articles","previous_headings":"Sorting Count Layers","what":"“byfactor” and “byvarn”","title":"Sorting a Tplyr Table","text":"“byfactor” default ordering method results count layers. “byfactor” “byvarn” behave exactly like order variables associated variables Tplyr table. “byvarn”, must set sort method using set_order_count_method().","code":"tplyr_adsl$AGEGR1 <- factor(tplyr_adsl$AGEGR1, c(\"<65\", \"65-80\", \">80\")) # Warnings suppressed to remove 'forcats' implicit NA warning suppressWarnings({ tplyr_table(tplyr_adsl, TRT01A) %>% add_layer( group_count(AGEGR1) %>% # This is the default and not needed set_order_count_method(\"byfactor\") ) %>% build() %>% select(row_label1, ord_layer_1) %>% kable() }) tplyr_table(tplyr_adsl, TRT01A) %>% add_layer( group_count(RACE) %>% set_order_count_method(\"byvarn\") ) %>% build() %>% select(row_label1, ord_layer_1) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"bycount","dir":"Articles","previous_headings":"Sorting Count Layers","what":"“bycount”","title":"Sorting a Tplyr Table","text":"Using count-based sorting things get complicated. multiple items consider: column want sort ? multiple numbers column, like “n (%) [event]” type tables, number used create sort variable? ’ve created helper functions aid making step intuitive user perspective, maintain flexibility need. two functions need set_ordering_cols() set_result_order_var(). example, results columns output table actually contain three different numbers: distinct counts, distinct percentage, non-distinct counts. want use distinct counts, choose distinct_n. next question need answer sorting counts result column take counts . , three results columns - one treatment group dataset. want use results treatment group “Xanomeline High Dose”, provide name treatment group. additional column variable top treatment groups? ’re ordering female subjects “Xanomeline High Dose” cohort. set_result_order_var(), need enter values variable treat_var variable entered cols ’d like extract.","code":"tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% # This will present 3 numbers in a cell set_format_strings(f_str(\"xx (xx.x%) [x]\", distinct_n, distinct_pct, n)) %>% # This makes the distinct numbers available set_distinct_by(USUBJID) %>% # Choosing \"bycount\" ordering for the result variable set_order_count_method(\"bycount\") %>% # This will target the results column for Xanomeline High Dose, or `var1_Xanomeline High Dose` set_ordering_cols(\"Xanomeline High Dose\") %>% # The number we want to pull out is the distinct N counts set_result_order_var(distinct_n) ) %>% build() %>% arrange(desc(ord_layer_1)) %>% select(row_label1, `var1_Xanomeline High Dose`, ord_layer_1) %>% head() %>% kable() tplyr_table(tplyr_adae, TRTA, cols=SEX) %>% add_layer( group_count(AEDECOD) %>% # This will present 3 numbers in a cell set_format_strings(f_str(\"xx (xx.x%) [x]\", distinct_n, distinct_pct, n)) %>% # This makes the distinct numbers available set_distinct_by(USUBJID) %>% # Choosing \"bycount\" ordering for the result variable set_order_count_method(\"bycount\") %>% # This will target the results column for Xanomeline High Dose, or `var1_Xanomeline High Dose` set_ordering_cols(\"Xanomeline High Dose\", \"F\") %>% # The number we want to pull out is the distinct N counts set_result_order_var(distinct_n) ) %>% build() %>% arrange(desc(ord_layer_1)) %>% select(row_label1, `var1_Xanomeline High Dose_F`, ord_layer_1) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"nested-sorting","dir":"Articles","previous_headings":"","what":"Nested Sorting","title":"Sorting a Tplyr Table","text":"Nested count layers add one piece puzzle. reminder, nested count layers count summaries summarizing grouping variable, variable ’s grouped. best example probably Adverse Event tables, want see adverse events occurred within different body systems. layer uses nesting, need one order variable - ’re now concerned sorting outside inside variable. Counts summarized - need know sorted. Additionally, need make sure , case, adverse events within body system stay within rows body system. result variables always last two order variables output Tplyr. example, ord_layer_1 AEBODSYS ord_layer_2 AEDECOD. Note ord_layer_2 Inf row_label1 row_label2 equal. row summarizes AEBODSYS counts. default, Tplyr set assume use descending sort order variable associated inside count variable (.e. AEDECOD). nested count layer often want sort descending occurrence inside target variable. ’d like use ascending sorting instead, offer function set_outer_sort_position(). Notice Inf now switched -Inf ensure AEBODSYS row stays top group. Another consideration nested sorting whether want sort result variables way. want sort counts? want sort one alphabetically count? maybe one VARN variable associated ? reason, set_order_count_method() can take 2-element character vector, first element specifies outside variable second inside variable. example , EOSTT ordered alphabetically (recall using “byfactor” variable factor alphabetical sorting), DSDECOD ordered count. one method provided, method automatically applied variables. example , “bycount” applied EOSTT DSDECOD.","code":"tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) ) %>% build() %>% head() %>% kable() tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) %>% set_outer_sort_position(\"asc\") ) %>% build() %>% arrange(ord_layer_1, ord_layer_2) %>% select(starts_with(\"row\"), starts_with(\"ord_layer\")) %>% head() %>% kable() tplyr_table(tplyr_adsl, TRT01A) %>% add_layer( group_count(vars(EOSSTT, DCDECOD)) %>% set_order_count_method(c(\"byfactor\", \"bycount\")) ) %>% build() %>% select(starts_with(\"row\"), starts_with(\"ord\")) %>% kable() tplyr_table(tplyr_adsl, TRT01A) %>% add_total_group() %>% add_layer( group_count(vars(EOSSTT, DCDECOD)) %>% set_order_count_method(\"bycount\") %>% #set_order_count_method(\"bycount\", \"bycount\") %>% This is functionally the same. set_ordering_cols(Total) ) %>% build() %>% select(starts_with(\"row\"), var1_Total, starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"sorting-shift-tables","dir":"Articles","previous_headings":"","what":"Sorting Shift Tables","title":"Sorting a Tplyr Table","text":"Shift tables keep things relatively simple comes sorting use “byfactor” method seen . encourage primarily likely want benefits factor variables shift layer. example, consider table: problems : “H” sorts “N” alphabetically ’re missing rows “L” visits, even though “L” data BNRIND. Using factor variables cleans right us: Now nice “L”, “N”, “H” order ’d like see. sort methods shift table fairly unlikely, matrix structure counts displayed shift tables relevant presentation interpreting results. Happy sorting!","code":"tplyr_table(tplyr_adlb, TRTA, where=PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, AVISIT)) ) %>% build() %>% select(-starts_with('var1')) %>% head(20) %>% kable() tplyr_adlb$BNRIND <- factor(tplyr_adlb$BNRIND, levels=c(\"L\", \"N\", \"H\")) tplyr_adlb$ANRIND <- factor(tplyr_adlb$ANRIND, levels=c(\"L\", \"N\", \"H\")) tplyr_table(tplyr_adlb, TRTA, where=PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, AVISIT)) ) %>% build() %>% select(-starts_with('var1')) %>% head(20) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/styled-table.html","id":"preparing-the-data","dir":"Articles","previous_headings":"","what":"Preparing the data","title":"Producing a Styled Table","text":"block , assembled count descriptive statistic summaries one one. notice pre-processing dataset. important considerations : Tplyr data cleaning. summarize prepare data enter. ’re following CDISC standards properly, shouldn’t concern - ADaM data already formatted presentation ready. Tplyr works assumption, won’t re-coding casing changes. example, original SEX values “M” “F” - switched “Male” “Female” instead. second pre-processing step something interesting. recall vignette(\"sort\"), factor variables input Tplyr use factor order resulting order variable. Another particularly useful advantage dummying values. adsl dataset contains races “WHITE”, “BLACK AFRICAN AMERICAN”, “AMERICAN INDIAN ALASK NATIVE”. set factor levels prior entering data Tplyr, values dummied . particularly advantageous study early data may sparse. output can display complete values presentation consistent data come . Data may sometimes need additional post-processing well. example, sometimes statisticians may want special formatting things like show percent count 0. function apply_conditional_formatting() can used post process character strings based numbers present within string. example, targetted count layers layer index (ord_layer_index) used dplyr::across() target result columns. Within apply_conditional_format() saying take string, look second number, ’s equal 0 replace entire string segment blank. information apply_conditional_format() function, see function documentation. now, ’ll leave data frame unedited rest example.","code":"tplyr_adsl <- tplyr_adsl %>% mutate( SEX = recode(SEX, M = \"Male\", F = \"Female\"), RACE = factor(RACE, c(\"AMERICAN INDIAN OR ALASKA NATIVE\", \"ASIAN\", \"BLACK OR AFRICAN AMERICAN\", \"NATIVE HAWAIIN OR OTHER PACIFIC ISLANDER\", \"WHITE\", \"MULTIPLE\")) ) t <- tplyr_table(tplyr_adsl, TRT01P) %>% add_total_group() %>% add_layer(name = 'Sex', group_count(SEX, by = \"Sex n (%)\") %>% set_missing_count(f_str('xx', n), Missing=NA, denom_ignore=TRUE) ) %>% add_layer(name = 'Age', group_desc(AGE, by = \"Age (Years)\") ) %>% add_layer(name = 'Age group', group_count(AGEGR1, by = \"Age Categories n (%)\") %>% set_missing_count(f_str('xx', n), Missing=NA, denom_ignore=TRUE) ) %>% add_layer(name = 'Race', group_count(RACE, by = \"Race n (%)\") %>% set_missing_count(f_str('xx', n), Missing=NA, denom_ignore=TRUE) %>% set_order_count_method(\"byfactor\") ) %>% add_layer(name = 'Ethnic', group_count(ETHNIC, by = \"Ethnicity n (%)\") %>% set_missing_count(f_str('xx', n), Missing=NA, denom_ignore=TRUE) ) dat <- build(t) dat %>% kable() dat %>% mutate( across(starts_with('var'), ~ if_else( ord_layer_index %in% c(1, 3:5), apply_conditional_format( string = ., format_group = 2, condition = x == 0, replacement = \"\" ), . ) ) ) #> # A tibble: 23 × 9 #> row_label1 row_label2 var1_Placebo var1_Total var1_Xanomeline High…¹ #> #> 1 Sex n (%) Female \" 53 ( 61.6… \"143 ( 56… \" 40 ( 47.6%)\" #> 2 Sex n (%) Male \" 33 ( 38.4… \"111 ( 43… \" 44 ( 52.4%)\" #> 3 Sex n (%) Missing \" 0\" \" 0\" \" 0\" #> 4 Age (Years) n \" 86\" \"254\" \" 84\" #> 5 Age (Years) Mean (SD) \"75.2 ( 8.5… \"75.1 ( 8… \"74.4 ( 7.89)\" #> 6 Age (Years) Median \"76.0\" \"77.0\" \"76.0\" #> 7 Age (Years) Q1, Q3 \"69.2, 81.8\" \"70.0, 81… \"70.8, 80.0\" #> 8 Age (Years) Min, Max \"52, 89\" \"51, 89\" \"56, 88\" #> 9 Age (Years) Missing \" 0\" \" 0\" \" 0\" #> 10 Age Categories n (… <65 \" 14 ( 16.3… \" 33 ( 13… \" 11 ( 13.1%)\" #> # ℹ 13 more rows #> # ℹ abbreviated name: ¹​`var1_Xanomeline High Dose` #> # ℹ 4 more variables: `var1_Xanomeline Low Dose` , ord_layer_index , #> # ord_layer_1 , ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/articles/styled-table.html","id":"sorting-column-ordering-column-headers-and-clean-up","dir":"Articles","previous_headings":"","what":"Sorting, Column Ordering, Column Headers, and Clean-up","title":"Producing a Styled Table","text":"Now data, let’s make sure ’s right order. Additionally, let’s clean data ’s ready present. Now can see things coming together. block, : Sorted data layer, row labels (case just text strings defined), results. Review vignette(\"sort\") understand layer handles sorting detail. Used apply_row_masks() function. Essentially, data sorted, function look row_label variables drop repeating values. packages like huxtable, eases process making table presentation ready, don’t need cell merging huxtable table created. Additionally, set row_breaks option TRUE. insert blank row layers, helps improve presentation depending output. ’s important note input dataset must still ord_layer_index variable attached order blank rows added. Sorting done prior, column reordering/dropping may done . Re-ordered columns dropped order columns. information get dplyr::select(), can look ‘tidyselect’ . tidyselect::starts_with() comes . Added column headers. huxtable, column headers basically just top rows data frame. Tplyr function add_column_headers() letting just enter string define headers. ’s - can also create nested headers nesting text within curly brackets ({}), notice treatment groups within two stars? actually allows take header N values Tplyr calculates , use within column headers. can see first row output, text shows (N=XX) values populated proper header_n counts.","code":"dat <- dat %>% arrange(ord_layer_index, ord_layer_1, ord_layer_2) %>% apply_row_masks(row_breaks = TRUE) %>% select(starts_with(\"row_label\"), var1_Placebo, `var1_Xanomeline Low Dose`, `var1_Xanomeline High Dose`, var1_Total) %>% add_column_headers( paste0(\" | | Placebo\\\\line(N=**Placebo**)| Xanomeline Low Dose\\\\line(N=**Xanomeline Low Dose**) \", \"| Xanomeline High Dose\\\\line(N=**Xanomeline High Dose**) | Total\\\\line(N=**Total**)\"), header_n = header_n(t)) dat %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/styled-table.html","id":"table-styling","dir":"Articles","previous_headings":"","what":"Table Styling","title":"Producing a Styled Table","text":"lot options go next. gt package always good choice, ’ve using kableExtra throughout vignettes. moment, tools ’ve made available Tplyr, ’re aiming create RTF outputs (still common requirement within pharma companies), huxtable package pharmaRTF get need go. (Note: plan extend pharmaRTF support GT better RTF support) Alright - table ready. Let’s prepare huxtable table.","code":"# Make the table ht <- huxtable::as_hux(dat, add_colnames=FALSE) %>% huxtable::set_bold(1, 1:ncol(dat), TRUE) %>% # bold the first row huxtable::set_align(1, 1:ncol(dat), 'center') %>% # Center align the first row huxtable::set_align(2:nrow(dat), 3:ncol(dat), 'center') %>% # Center align the results huxtable::set_valign(1, 1:ncol(dat), 'bottom') %>% # Bottom align the first row huxtable::set_bottom_border(1, 1:ncol(dat), 1) %>% # Put a border under the first row huxtable::set_width(1.5) %>% # Set the table width huxtable::set_escape_contents(FALSE) %>% # Don't escape RTF syntax huxtable::set_col_width(c(.2, .2, .15, .15, .15, .15)) # Set the column widths ht"},{"path":"https://atorus-research.github.io/Tplyr/articles/styled-table.html","id":"output-to-file","dir":"Articles","previous_headings":"","what":"Output to File","title":"Producing a Styled Table","text":"now starting look lot like ’re going ! table styling coming together. last step get final output document. ’ll jump pharmaRTF may look little messy, pharmaRTF syntax can abbreviated standardizing process. Check vignette instructions read titles footnotes ‘pharmaRTF’ file. document now created, titles footnotes added, settings good go. Last step write . - table styled ready go! ’d like learn use huxtable, sure check website. use specifically pharmaRTF, prepared vignette tips tricks .","code":"doc <- pharmaRTF::rtf_doc(ht) %>% pharmaRTF::add_titles( pharmaRTF::hf_line(\"Protocol: CDISCPILOT01\", \"PAGE_FORMAT: Page %s of %s\", align='split', bold=TRUE, italic=TRUE), pharmaRTF::hf_line(\"Table 14-2.01\", align='center', bold=TRUE, italic=TRUE), pharmaRTF::hf_line(\"Summary of Demographic and Baseline Characteristics\", align='center', bold=TRUE, italic=TRUE) ) %>% pharmaRTF::add_footnotes( pharmaRTF::hf_line(\"FILE_PATH: Source: %s\", \"DATE_FORMAT: %H:%M %A, %B %d, %Y\", align='split', bold=FALSE, italic=TRUE) ) %>% pharmaRTF::set_font_size(10) %>% pharmaRTF::set_ignore_cell_padding(TRUE) %>% pharmaRTF::set_column_header_buffer(top=1) pharmaRTF::write_rtf(doc, file='styled_example.rtf')"},{"path":"https://atorus-research.github.io/Tplyr/articles/table.html","id":"table-parameters","dir":"Articles","previous_headings":"","what":"Table Parameters","title":"Tplyr Table Properties","text":"tplyr_table() function 4 parameters: target: dataset upon summaries performed treat_var: variable containing treatment group assignments : overarching table subset criteria. layer use subset default. parameter table level called addition layer subset criteria. cols: Grouping variables used addition variables set layer level, transposed columns addition treat_var. Let’s look example: example , parameter passed forward RACE AGE layers. Furthermore, note cols parameter works. default, target variables layers transposed treat_var variables. cols argument adds additional variable transpose , values variable added suffix variable name. able use multiple cols variables just like , using dplyr::vars(). use caution - depending distinct variable values dataset, get quite wide. Note: Treatment groups additional column variables presented final output always taken pre-filtered population data. means filter completed excludes treatment group group within column variable, columns still created groups empty/zero filled.","code":"tplyr_table(tplyr_adsl, TRT01P, where= SAFFL ==\"Y\", cols = SEX) %>% add_layer( group_count(RACE, by = \"Race\") ) %>% add_layer( group_desc(AGE, by = \"Age (Years)\") ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P, where= SAFFL ==\"Y\", cols = vars(SEX, RACE)) %>% add_layer( group_desc(AGE, by = \"Age (Years)\") ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/table.html","id":"additional-treatment-groups","dir":"Articles","previous_headings":"","what":"Additional Treatment Groups","title":"Tplyr Table Properties","text":"Another important feature works table level addition treatment groups. adding additional treatment groups, ’re able number things: Add ‘treated’ group data can analyze ‘treated’ vs. ‘placebo’ multiple treated cohorts Add ‘total’ group summarize overall study population ’ve added function add_treat_grps() work . function, can create new treatment groups combining existing treatment groups values within treat_var. Additionally, simplify process added abstraction add_treat_grps() named add_total_group() simplify process creating “Total” group. Note example, two new columns added data - var1_Total var1_Treated. summaries individual cohorts left unchanged.","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_treat_grps('Treated' = c(\"Xanomeline High Dose\", \"Xanomeline Low Dose\")) %>% add_total_group() %>% add_layer( group_desc(AGE, by = \"Age (Years)\") ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/table.html","id":"population-data","dir":"Articles","previous_headings":"","what":"Population Data","title":"Tplyr Table Properties","text":"last important aspect table level properties Tplyr addition population dataset. CDISC standards, datasets like adae contain adverse events occur. means subject experience adverse event, experience adverse event within criteria ’re subsetting , don’t appear dataset. ’re looking proportion subject experienced adverse event compared total number subjects cohort, adae leaves way calculate total - subjects won’t exist data. Tplyr allows provide separate population dataset overcome . Furthermore, also able provide separate population dataset parameter population treatment variable named pop_treat_var, variable names may differ datasets. example, AEREL doesn’t exist adsl, therefore used set_pop_where() remove filter criteria population data. Setting population dataset parameter TRUE removes filter applied population data. set_pop_where() set population data, default parameter used tplyr_table(). logic applies population treatment variable. TRTA exist adsl either, used set_pop_treat_var() change appropriate variable adsl. Note percentage values summary . setting population data, Tplyr now knew use values calculating percentages distinct counts subjects experienced summarized adverse events. Furthermore, population data provided, Tplyr able calculate header N’s properly: Note: ’s expected set_distinct_by() function used population data. make sense use population data denominators unless distinct counts. entire point population data use subject counts, non-distinct counts potentially count multiple records per subject percentage doesn’t make sense.","code":"t <- tplyr_table(tplyr_adae, TRTA, where = AEREL != \"NONE\") %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% set_pop_where(TRUE) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) ) t %>% build() %>% kable() header_n(t) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/table.html","id":"data-completion","dir":"Articles","previous_headings":"","what":"Data Completion","title":"Tplyr Table Properties","text":"creating summary tables, often mock potential values data, even values aren’t present data ’re summarizing. Tplyr best effort . Let’s consider following dataset: Let’s say want create count summary dataset, report PARAM AVISIT. Note data, PARAM==\"HEAD\" collected screening, LUNGS collected Screening, Day -1, Day 5. default, given variables PARAM AVISIT, potential visits dummy rows created 0 filled - meaning results 0 records treatment groups presented. However, might wish present. Perhaps HEAD intended collected Screening visit ’s unnecessary present visits. address , can use set_limit_data_by() function. can see now records HEAD present screening visit. count shift layers, can additionally dig use target variables: effectively limits values present data .","code":"tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_count(AVALC, by = vars(PARAM, AVISIT)) ) %>% build() %>% select(-starts_with('ord')) %>% head(18) %>% kable() tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_count(AVALC, by = vars(PARAM, AVISIT)) %>% set_limit_data_by(PARAM, AVISIT) ) %>% build() %>% select(-starts_with('ord')) %>% head(12) %>% kable() tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_count(AVALC, by = vars(PARAM, AVISIT)) %>% set_limit_data_by(PARAM, AVISIT, AVALC) ) %>% build() %>% select(-starts_with('ord')) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/table.html","id":"where-to-go-from-here","dir":"Articles","previous_headings":"","what":"Where to Go From Here","title":"Tplyr Table Properties","text":"table level settings control, now ’re ready learn Tplyr offer layer. Learn descriptive statistics layers vignette(\"desc\") Learn count shift layers vignette(\"count\") Learn shift layers vignette(\"shift\") Learn calculating risk differences vignette(\"riskdiff\") Learn sorting Tplyr tables vignette(\"sort\") Learn using Tplyr options vignette(\"options\") finally, learn producing outputting styled tables using Tplyr vignette(\"styled-table\")","code":""},{"path":"https://atorus-research.github.io/Tplyr/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Eli Miller. Author. Mike Stackhouse. Author, maintainer. Ashley Tarasiewicz. Author. Nathan Kosiba. Contributor. Sadchla Mascary. Contributor. Andrew Bates. Contributor. Shiyu Chen. Contributor. Oleksii Mikryukov. Contributor. Atorus Research LLC. Copyright holder.","code":""},{"path":"https://atorus-research.github.io/Tplyr/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Miller E, Stackhouse M, Tarasiewicz (2024). Tplyr: Traceability Focused Grammar Clinical Data Summary. R package version 1.2.1, https://github.com/atorus-research/Tplyr.","code":"@Manual{, title = {Tplyr: A Traceability Focused Grammar of Clinical Data Summary}, author = {Eli Miller and Mike Stackhouse and Ashley Tarasiewicz}, year = {2024}, note = {R package version 1.2.1}, url = {https://github.com/atorus-research/Tplyr}, }"},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"tplyr-","dir":"","previous_headings":"","what":"A Traceability Focused Grammar of Clinical Data Summary","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"Welcome Tplyr! Tplyr traceability minded grammar data format summary. ’s designed simplify creation common clinical summaries help focus present data rather redundant summaries performed. Furthermore, every result Tplyr produces, also produces metadata necessary give traceability source summary. always, welcome feedback. spot bug, like see new feature, documentation unclear - submit issue GitHub right . Take look cheatsheet!","code":""},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"can install Tplyr :","code":"# Install from CRAN: install.packages(\"Tplyr\") # Or install the development version: devtools::install_github(\"https://github.com/atorus-research/Tplyr.git\", ref=\"devel\")"},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"what-is-tplyr","dir":"","previous_headings":"","what":"What is Tplyr?","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"dplyr tidyverse grammar data manipulation. allow ? gives , data analyst, capability easily intuitively approach problem manipulating data analysis ready form. dplyr conceptually breaks things verbs allow focus want . Tplyr designed around similar concept, focus building summary tables common within clinical world. pharmaceutical industry, great deal data presented outputs create similar. part, tables can broken categories: Counting event based variables categories Shifting, just counting change state ‘’ ‘’ Generating descriptive statistics around continuous variable. many tables go clinical submission, tables made combination approaches. Consider demographics table - let’s use example PHUSE project Standard Analyses & Code Sharing - Analyses & Displays Associated Demographics, Disposition, Medications Phase 2-4 Clinical Trials Integrated Summary Documents. look table, can begin breaking output smaller, redundant, components. components can viewed ‘layers’, table whole constructed stacking layers. boxes image represent can begin conceptualize . First Sex, made n (%) counts. Next Age continuous variable, number descriptive statistics, including n, mean, standard deviation, median, quartile 1, quartile 3, min, max, missing values. age, broken categories - n (%) values. Race - counting, Ethnicity - counting Weight - ’re back descriptive statistics. one table, 6 summaries (7 including next page, shown) - 2 different approaches summaries performed. way dplyr grammar data manipulation, Tplyr aims grammar data summary. goal Tplyr allow program summary table like see page, breaking larger problem smaller ‘layers’, combining together like see page. Enough talking - let’s see code. examples, using data PHUSE Test Data Factory based original pilot project submission package. ’ve packaged subsets data Tplyr, can use replicate examples run vignette code . Note: can see replication CDISC pilot using PHUSE Test Data Factory data .","code":"tplyr_table(tplyr_adsl, TRT01P, where = SAFFL == \"Y\") %>% add_layer( group_desc(AGE, by = \"Age (years)\") ) %>% add_layer( group_count(AGEGR1, by = \"Age Categories n (%)\") ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"tplyr-is-qualified","dir":"","previous_headings":"","what":"Tplyr is Qualified","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"understand important documentation testing within pharmaceutical world. outside unit testing Tplyr includes entire user-acceptance testing document, requirements established, test-cases written, tests independently programmed executed. hope can leverage work within qualified programming environment, save substantial amount trouble getting . can find qualification document within repository right . ‘uat’ folder additionally contains raw files, programmatic tests, specifications, test cases necessary create report.","code":""},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"the-tldr","dir":"","previous_headings":"","what":"The TL;DR","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"high level benefits using Tplyr: Easy construction table data using intuitive syntax Smart string formatting numbers ’s easily specified user great deal flexibility performed ’s presented, without specifying hundreds parameters","code":""},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"where-to-go-from-here","dir":"","previous_headings":"","what":"Where to go from here?","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"’s quite bit learn! ’ve prepared number vignettes help get need Tplyr. best place start Getting Started vignette vignette(\"Tplyr\") Learn table level settings vignette(\"table\") Learn descriptive statistics layers vignette(\"desc\") Learn count layers vignette(\"count\") Learn shift layers vignette(\"shift\") Learn percentages vignette(\"denom\") Learn calculating risk differences vignette(\"riskdiff\") Learn sorting Tplyr tables vignette(\"sort\") Learn using Tplyr options vignette(\"options\") finally, learn producing outputting styled tables using Tplyr vignette(\"styled-table\") Tplyr version 1.0.0, ’ve packed number new features . deeper dives largest new additions: Learn Tplyr’s traceability metadata vignette(\"metadata\") can extended vignette(\"custom-metadata\") Learn layer templates vignette(\"layer_templates\")","code":""},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"references","dir":"","previous_headings":"","what":"References","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"building Tplyr, needed additional resources addition personal experience help guide design. PHUSE done great work create guidance standard outputs collaboration multiple pharmaceutical companies FDA. can find resource referenced . Analysis Displays Associated Adverse Events Analyses Displays Associated Demographics, Disposition, Medications Analyses Displays Associated Measures Central Tendency","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/Tplyr.html","id":null,"dir":"Reference","previous_headings":"","what":"A grammar of summary data for clinical reports — Tplyr","title":"A grammar of summary data for clinical reports — Tplyr","text":"`r lifecycle::badge(\"experimental\")`","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/Tplyr.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"A grammar of summary data for clinical reports — Tplyr","text":"'Tplyr' package dedicated simplifying data manipulation necessary create clinical reports. Clinical data summaries can often broken two factors - counting discrete variables (counting shifts state), descriptive statistics around continuous variable. Many reports go clinical report made two scenarios. abstracting process away, 'Tplyr' allows rapidly build tables without worrying underlying data manipulation. 'Tplyr' takes process steps abstracting away programming goes proper presentation, great deal programming time spent. example, 'Tplyr' allows easily control: String formatting Different reports warrant different presentation strings. Programming can get tedious, typically want make sure decimals properly align. 'Tplyr' abstracts process away provides simple interface specify want data presented Treatment groups Need total column? Need group summaries multiple treatments? 'Tplyr' makes simple add additional treatment groups report Denominators n (%) counts often vary based summary performed. 'Tplyr' allows easily control denominators used based common scenarios Sorting Summarizing data one thing, ordering presentation. Tplyr automatically derives sorting variable give data need order table properly. process flexible can easily get want leveraging data characteristics R. Another powerful aspect 'Tplyr' objects . 'Tplyr' format data. Metadata table kept hood, functions allow access information need. example, 'Tplyr' allows calculate access raw numeric data calculations well, easily pick just pieces information need. Lastly, 'Tplyr' built flexible, yet intuitive. common pitfall building tools like automation. much, end enough. 'Tplyr' aims hit sweet spot . Additionally, designed function interfaces clean. Modifier functions offer flexibility need , defaults can set keep code concise. allows quickly assemble table, easily make changes necessary.","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/Tplyr.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"A grammar of summary data for clinical reports — Tplyr","text":"Maintainer: Mike Stackhouse mike.stackhouse@atorusresearch.com (ORCID) Authors: Eli Miller Eli.Miller@AtorusResearch.com (ORCID) Ashley Tarasiewicz Ashley.Tarasiewicz@atorusresearch.com contributors: Nathan Kosiba Nathan.Kosiba@atorusresearch.com (ORCID) [contributor] Sadchla Mascary sadchla.mascary@atorusresearch.com [contributor] Andrew Bates andrew.bates@atorusresearch.com [contributor] Shiyu Chen shiyu.chen@atorusresearch.com [contributor] Oleksii Mikryukov alex.mikryukov@atorusresearch.com [contributor] Atorus Research LLC [copyright holder]","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/Tplyr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"A grammar of summary data for clinical reports — Tplyr","text":"","code":"# Load in pipe library(magrittr) # Use just the defaults tplyr_table(mtcars, gear) %>% add_layer( group_desc(mpg, by=cyl) ) %>% add_layer( group_count(carb, by=cyl) ) %>% build() #> # A tibble: 36 × 8 #> row_label1 row_label2 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 n \" 1\" \" 8\" \" 2\" 1 1 #> 2 4 Mean (SD) \"21.50 ( … \"26.9… \"28.2… 1 1 #> 3 4 Median \"21.50\" \"25.8… \"28.2… 1 1 #> 4 4 Q1, Q3 \"21.50, 21.5… \"22.8… \"27.1… 1 1 #> 5 4 Min, Max \"21.5, 21.5\" \"21.4… \"26.0… 1 1 #> 6 4 Missing \" 0\" \" 0\" \" 0\" 1 1 #> 7 6 n \" 2\" \" 4\" \" 1\" 1 2 #> 8 6 Mean (SD) \"19.75 ( 2.3… \"19.7… \"19.7… 1 2 #> 9 6 Median \"19.75\" \"20.1… \"19.7… 1 2 #> 10 6 Q1, Q3 \"18.92, 20.5… \"18.8… \"19.7… 1 2 #> # ℹ 26 more rows #> # ℹ 1 more variable: ord_layer_2 # Customize and modify tplyr_table(mtcars, gear) %>% add_layer( group_desc(mpg, by=cyl) %>% set_format_strings( \"n\" = f_str(\"xx\", n), \"Mean (SD)\" = f_str(\"a.a+1 (a.a+2)\", mean, sd, empty='NA'), \"Median\" = f_str(\"a.a+1\", median), \"Q1, Q3\" = f_str(\"a, a\", q1, q3, empty=c(.overall='NA')), \"Min, Max\" = f_str(\"a, a\", min, max), \"Missing\" = f_str(\"xx\", missing) ) ) %>% add_layer( group_count(carb, by=cyl) %>% add_risk_diff( c('5', '3'), c('4', '3') ) %>% set_format_strings( n_counts = f_str('xx (xx%)', n, pct), riskdiff = f_str('xx.xxx (xx.xxx, xx.xxx)', dif, low, high) ) %>% set_order_count_method(\"bycount\") %>% set_ordering_cols('4') %>% set_result_order_var(pct) ) %>% build() #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> # A tibble: 36 × 10 #> row_label1 row_label2 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 n \" 1\" \" 8\" \" 2\" 1 1 #> 2 4 Mean (SD) \"21.50 ( … \"26.9… \"28.2… 1 1 #> 3 4 Median \"21.50\" \"25.8… \"28.2… 1 1 #> 4 4 Q1, Q3 \"22, 22\" \"23, … \"27, … 1 1 #> 5 4 Min, Max \"22, 22\" \"21, … \"26, … 1 1 #> 6 4 Missing \" 0\" \" 0\" \" 0\" 1 1 #> 7 6 n \" 2\" \" 4\" \" 1\" 1 2 #> 8 6 Mean (SD) \"19.75 ( 2.3… \"19.7… \"19.7… 1 2 #> 9 6 Median \"19.75\" \"20.1… \"19.7… 1 2 #> 10 6 Q1, Q3 \"19, 21\" \"19, … \"20, … 1 2 #> # ℹ 26 more rows #> # ℹ 3 more variables: ord_layer_2 , rdiff_5_3 , rdiff_4_3 # A Shift Table tplyr_table(mtcars, am) %>% add_layer( group_shift(vars(row=gear, column=carb), by=cyl) %>% set_format_strings(f_str(\"xxx (xx.xx%)\", n, pct)) ) %>% build() #> # A tibble: 9 × 17 #> row_label1 row_label2 var1_0_1 var1_0_2 var1_0_3 var1_0_4 var1_0_6 var1_0_8 #> #> 1 4 3 \" 1 (33.3… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 2 4 4 \" 0 ( 0.0… \" 2 (6… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 3 4 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 4 6 3 \" 2 (50.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 5 6 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 2 (5… \" 0 ( … \" 0 ( … #> 6 6 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 7 8 3 \" 0 ( 0.0… \" 4 (3… \" 3 (2… \" 5 (4… \" 0 ( … \" 0 ( … #> 8 8 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 9 8 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> # ℹ 9 more variables: var1_1_1 , var1_1_2 , var1_1_3 , #> # var1_1_4 , var1_1_6 , var1_1_8 , ord_layer_index , #> # ord_layer_1 , ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/reference/add_anti_join.html","id":null,"dir":"Reference","previous_headings":"","what":"Add an anti-join onto a tplyr_meta object — add_anti_join","title":"Add an anti-join onto a tplyr_meta object — add_anti_join","text":"anti-join allows tplyr_meta object refer data extracted separate dataset, like population data Tplyr table, unavailable target dataset. primary use case presentation missing subjects, Tplyr table presented using function add_missing_subjects_row(). missing subjects present target data, thus available population data. add_anti_join() function allows provide meta information relevant population data, specify variable used join target dataset find values present population data missing target data.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_anti_join.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add an anti-join onto a tplyr_meta object — add_anti_join","text":"","code":"add_anti_join(meta, join_meta, on)"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_anti_join.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add an anti-join onto a tplyr_meta object — add_anti_join","text":"meta tplyr_meta object referring target data join_meta tplyr_meta object referring population data list quosures containing symbols - likely set USUBJID.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_anti_join.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add an anti-join onto a tplyr_meta object — add_anti_join","text":"tplyr_meta object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_anti_join.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add an anti-join onto a tplyr_meta object — add_anti_join","text":"","code":"tm <- tplyr_meta( rlang::quos(TRT01A, SEX, ETHNIC, RACE), rlang::quos(TRT01A == \"Placebo\", TRT01A == \"SEX\", ETHNIC == \"HISPANIC OR LATINO\") ) tm %>% add_anti_join( tplyr_meta( rlang::quos(TRT01A, ETHNIC), rlang::quos(TRT01A == \"Placebo\", ETHNIC == \"HISPANIC OR LATINO\") ), on = rlang::quos(USUBJID) ) #> tplyr_meta: 4 names, 3 filters #> Names: #> TRT01A, SEX, ETHNIC, RACE #> Filters: #> TRT01A == \"Placebo\", TRT01A == \"SEX\", ETHNIC == \"HISPANIC OR LATINO\" #> Anti-join: #> Join Meta: #> tplyr_meta: 2 names, 2 filters #> Names: #> TRT01A, ETHNIC #> Filters: #> TRT01A == \"Placebo\", ETHNIC == \"HISPANIC OR LATINO\" #> On: #> USUBJID"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":null,"dir":"Reference","previous_headings":"","what":"Attach column headers to a Tplyr output — add_column_headers","title":"Attach column headers to a Tplyr output — add_column_headers","text":"working 'huxtable' tables, column headers can controlled rows data frame. add_column_headers eases process introducing headers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Attach column headers to a Tplyr output — add_column_headers","text":"","code":"add_column_headers(.data, s, header_n = NULL)"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Attach column headers to a Tplyr output — add_column_headers","text":".data data.frame/tibble headers shall attached s text containing intended header string header_n header_n generic data.frame use binding count values. required using token replacement.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Attach column headers to a Tplyr output — add_column_headers","text":"data.frame processed header string elements attached top rows","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Attach column headers to a Tplyr output — add_column_headers","text":"Headers created providing single string. Columns specified delimitting header '|' symbol. Instead specifying destination header, add_column_headers assumes organized columns data frame hand. means use Tplyr::build(), like reorganize default column order (simply alphabetical), simply pass build output dplyr::select dplyr::relocate statement passing add_column_headers. Spanning headers also supported. spanning header overarching header sits across multiple columns. Spanning headers introduced add_column_header providing spanner text (.e. text like sit top row), spanned text (bottom row) within curly brackets ('{}). example, take iris dataset. names: \"Sepal.Length\" \"Sepal.Width\" \"Petal.Length\" \"Petal.Width\" \"Species\" wanted provide header string dataset, spanners help categorization variables, provide following string: \"Sepal {Length | Width} | Petal {Length | Width} | Species\"","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"important-note","dir":"Reference","previous_headings":"","what":"Important note","title":"Attach column headers to a Tplyr output — add_column_headers","text":"Make sure aware order variables prior passing add_column_headers. requirement number column match. rest .","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"development-notes","dir":"Reference","previous_headings":"","what":"Development notes","title":"Attach column headers to a Tplyr output — add_column_headers","text":"features add_column_header intended yet supported: Nested spanners yet supported. spanning row bottom row can currently created Different delimiters indicators spanned group may used future. current choices intuitive, based feedback determined less common characters may necessary.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"token-replacement","dir":"Reference","previous_headings":"","what":"Token Replacement","title":"Attach column headers to a Tplyr output — add_column_headers","text":"function support reading values header_n object Tplyr table adding column headers. Note: order parameters passed token important. first treatment variable cols variables order passed table construction. Use double asterisk \"**\" begining start token another double asterisk close . can separate column parameters token single underscore. example, **group1_flag2_param3** pull count header_n binding group1 treat_var, flag2 first cols argument, param3 second cols argument. can pass fewer arguments token get sum multiple columns. example, **group1** get sum group1 treat_var, cols header_n.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Attach column headers to a Tplyr output — add_column_headers","text":"","code":"# Load in pipe library(magrittr) library(dplyr) #> #> Attaching package: ‘dplyr’ #> The following objects are masked from ‘package:stats’: #> #> filter, lag #> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union header_string <- \"Sepal {Length | Width} | Petal {Length | Width} | Species\" iris2 <- iris %>% mutate_all(as.character) iris2 %>% add_column_headers(header_string) #> # A tibble: 152 × 5 #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> #> 1 Sepal \"\" Petal \"\" \"\" #> 2 Length \"Width\" Length \"Width\" \"Species\" #> 3 5.1 \"3.5\" 1.4 \"0.2\" \"setosa\" #> 4 4.9 \"3\" 1.4 \"0.2\" \"setosa\" #> 5 4.7 \"3.2\" 1.3 \"0.2\" \"setosa\" #> 6 4.6 \"3.1\" 1.5 \"0.2\" \"setosa\" #> 7 5 \"3.6\" 1.4 \"0.2\" \"setosa\" #> 8 5.4 \"3.9\" 1.7 \"0.4\" \"setosa\" #> 9 4.6 \"3.4\" 1.4 \"0.3\" \"setosa\" #> 10 5 \"3.4\" 1.5 \"0.2\" \"setosa\" #> # ℹ 142 more rows # Example with counts mtcars2 <- mtcars %>% mutate_all(as.character) t <- tplyr_table(mtcars2, vs, cols = am) %>% add_layer( group_count(cyl) ) b_t <- build(t) %>% mutate_all(as.character) count_string <- paste0(\" | V N=**0** {auto N=**0_0** | man N=**0_1**} |\", \" S N=**1** {auto N=**1_0** | man N=**1_1**} | | \") add_column_headers(b_t, count_string, header_n(t)) #> # A tibble: 5 × 7 #> row_label1 var1_0_0 var1_0_1 var1_1_0 var1_1_1 ord_layer_index ord_layer_1 #> #> 1 \"\" \"V N=18\" \"\" \"S N=14\" \"\" \"\" \"\" #> 2 \"\" \"auto N=12\" \"man N=… \"auto N… \"man N=… \"\" \"\" #> 3 \"4\" \" 0 ( 0.0%… \" 1 ( 1… \" 3 ( 4… \" 7 (10… \"1\" \"1\" #> 4 \"6\" \" 0 ( 0.0%… \" 3 ( 5… \" 4 ( 5… \" 0 ( … \"1\" \"2\" #> 5 \"8\" \"12 (100.0%… \" 2 ( 3… \" 0 ( … \" 0 ( … \"1\" \"3\""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_missing_subjects_row.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a missing subject row into a count summary. — add_missing_subjects_row","title":"Add a missing subject row into a count summary. — add_missing_subjects_row","text":"function calculates number subjects missing particular group results. calculation done examining total number subjects potentially available Header N values within result column, finding difference total number subjects present result group. Note accurate results, subject variable needs defined using `set_distinct_by()` function. methods, function instructs distinct results identified.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_missing_subjects_row.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a missing subject row into a count summary. — add_missing_subjects_row","text":"","code":"add_missing_subjects_row(e, fmt = NULL, sort_value = NULL)"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_missing_subjects_row.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a missing subject row into a count summary. — add_missing_subjects_row","text":"e `count_layer` object fmt f_str object used format total row. none provided, display based layer formatting. sort_value value appear ordering column total rows. must numeric value.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_missing_subjects_row.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a missing subject row into a count summary. — add_missing_subjects_row","text":"","code":"tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% add_missing_subjects_row(f_str(\"xxxx\", n)) ) %>% build() #> Warning: \tPopulation data was not set separately from the target data. #> \tMissing subject counts may be misleading in this scenario. #> \tDid you mean to use `set_missing_count() instead? #> # A tibble: 4 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 6 \" 2 ( 13.3%)\" \" 4 ( 33.3%)\" \" 1 ( 20.0… 1 2 #> 3 8 \"12 ( 80.0%)\" \" 0 ( 0.0%)\" \" 2 ( 40.0… 1 3 #> 4 Missing \" \" \" \" \" \" 1 4"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_risk_diff.html","id":null,"dir":"Reference","previous_headings":"","what":"Add risk difference to a count layer — add_risk_diff","title":"Add risk difference to a count layer — add_risk_diff","text":"common requirement summary tables calculate risk difference treatment groups. add_risk_diff allows . underlying risk difference calculations performed using Base R function prop.test - prior using function, sure familiarize functionality.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_risk_diff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add risk difference to a count layer — add_risk_diff","text":"","code":"add_risk_diff(layer, ..., args = list(), distinct = TRUE)"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_risk_diff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add risk difference to a count layer — add_risk_diff","text":"layer Layer upon risk difference attached ... Comparison groups, provided character vectors first group comparison, second reference args Arguments passed directly prop.test distinct Logical - Use distinct counts (available).","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_risk_diff.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add risk difference to a count layer — add_risk_diff","text":"add_risk_diff can attached count layer, count layer must constructed first. add_risk_diff allows compare difference treatment group, comparisons based upon values within specified treat_var tplyr_table object. Comparisons specified providing two-element character vectors. can provide many groups want. can also use groups constructed using add_treat_grps add_total_group. first element provided considered 'reference' group (.e. left side comparison), second group considered 'comparison'. like see risk difference 'T1 - Placebo', specify c('T1', 'Placebo'). Tplyr forms two-way table background, runs prop.test appropriately. Similar way display layers specified, exact values format like risk difference display set using set_format_strings. controls values format risk difference displayed. Risk difference formats set within set_format_strings using name 'riskdiff'. 5 variables choose data presentation: comp Probability left hand side group (.e. comparison) ref Probability right hand side group (.e. reference) dif Difference comparison - reference low Lower end confidence interval (default 95%, override args paramter) high Upper end confidence interval (default 95%, override args paramter) Use variable names forming f_str objects. default presentation, string format specified, : f_str('xx.xxx (xx.xxx, xx.xxx)', dif, low, high) Note - within Tplyr, can account negatives allowing extra space within integer side settings. help alignment. columns specified Tplyr table, risk difference comparisons still take place groups within treat_var variable - instead calculated treating cols variables variables. Just like tplyr layers , risk difference transposed display risk difference separate variables cols variables. distinct TRUE (default), calculations take place distinct counts, available. Otherwise, non-distinct counts used. One final note - prop.test may throw quite warnings. natural, alerts enough data approximations correct. may unnerving coming SAS programming world, R trying alert values provided enough data truly statistically accurate.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_risk_diff.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add risk difference to a count layer — add_risk_diff","text":"","code":"library(magrittr) ## Two group comparisons with default options applied t <- tplyr_table(mtcars, gear) # Basic risk diff for two groups, using defaults l1 <- group_count(t, carb) %>% # Compare 3 vs. 4, 3 vs. 5 add_risk_diff( c('3', '4'), c('3', '5') ) # Build and show output add_layers(t, l1) %>% build() #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> # A tibble: 6 × 8 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index rdiff_3_4 rdiff_3_5 #> #> 1 1 3 ( 20.0%) 4 ( 33.3%) 0 ( 0.0… 1 \"-0.133 … \" 0.200 … #> 2 2 4 ( 26.7%) 4 ( 33.3%) 2 ( 40.0… 1 \"-0.067 … \"-0.133 … #> 3 3 3 ( 20.0%) 0 ( 0.0%) 0 ( 0.0… 1 \" 0.200 … \" 0.200 … #> 4 4 5 ( 33.3%) 4 ( 33.3%) 1 ( 20.0… 1 \" 0.000 … \" 0.133 … #> 5 6 0 ( 0.0%) 0 ( 0.0%) 1 ( 20.0… 1 \" 0.000 … \"-0.200 … #> 6 8 0 ( 0.0%) 0 ( 0.0%) 1 ( 20.0… 1 \" 0.000 … \"-0.200 … #> # ℹ 1 more variable: ord_layer_1 ## Specify custom formats and display variables t <- tplyr_table(mtcars, gear) # Create the layer with custom formatting l2 <- group_count(t, carb) %>% # Compare 3 vs. 4, 3 vs. 5 add_risk_diff( c('3', '4'), c('3', '5') ) %>% set_format_strings( 'n_counts' = f_str('xx (xx.x)', n, pct), 'riskdiff' = f_str('xx.xxx, xx.xxx, xx.xxx, xx.xxx, xx.xxx', comp, ref, dif, low, high) ) # Build and show output add_layers(t, l2) %>% build() #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> # A tibble: 6 × 8 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index rdiff_3_4 rdiff_3_5 #> #> 1 1 \" 3 (20.0)\" \" 4 (33.3)\" \" 0 ( … 1 \" 0.200,… \" 0.200,… #> 2 2 \" 4 (26.7)\" \" 4 (33.3)\" \" 2 (4… 1 \" 0.267,… \" 0.267,… #> 3 3 \" 3 (20.0)\" \" 0 ( 0.0)\" \" 0 ( … 1 \" 0.200,… \" 0.200,… #> 4 4 \" 5 (33.3)\" \" 4 (33.3)\" \" 1 (2… 1 \" 0.333,… \" 0.333,… #> 5 6 \" 0 ( 0.0)\" \" 0 ( 0.0)\" \" 1 (2… 1 \" 0.000,… \" 0.000,… #> 6 8 \" 0 ( 0.0)\" \" 0 ( 0.0)\" \" 1 (2… 1 \" 0.000,… \" 0.000,… #> # ℹ 1 more variable: ord_layer_1 ## Passing arguments to prop.test t <- tplyr_table(mtcars, gear) # Create the layer with args option l3 <- group_count(t, carb) %>% # Compare 3 vs. 4, 4 vs. 5 add_risk_diff( c('3', '4'), c('3', '5'), args = list(conf.level = 0.9, correct=FALSE, alternative='less') ) # Build and show output add_layers(t, l3) %>% build() #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> # A tibble: 6 × 8 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index rdiff_3_4 rdiff_3_5 #> #> 1 1 3 ( 20.0%) 4 ( 33.3%) 0 ( 0.0… 1 \"-0.133 … \" 0.200 … #> 2 2 4 ( 26.7%) 4 ( 33.3%) 2 ( 40.0… 1 \"-0.067 … \"-0.133 … #> 3 3 3 ( 20.0%) 0 ( 0.0%) 0 ( 0.0… 1 \" 0.200 … \" 0.200 … #> 4 4 5 ( 33.3%) 4 ( 33.3%) 1 ( 20.0… 1 \" 0.000 … \" 0.133 … #> 5 6 0 ( 0.0%) 0 ( 0.0%) 1 ( 20.0… 1 \" 0.000 … \"-0.200 … #> 6 8 0 ( 0.0%) 0 ( 0.0%) 1 ( 20.0… 1 \" 0.000 … \"-0.200 … #> # ℹ 1 more variable: ord_layer_1 "},{"path":"https://atorus-research.github.io/Tplyr/reference/add_total_row.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a Total row into a count summary. — add_total_row","title":"Add a Total row into a count summary. — add_total_row","text":"Adding total row creates additional observation count summary presents total counts (.e. n's summarized). format total row formatted way count strings.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_total_row.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a Total row into a count summary. — add_total_row","text":"","code":"add_total_row(e, fmt = NULL, count_missings = TRUE, sort_value = NULL)"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_total_row.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a Total row into a count summary. — add_total_row","text":"e count_layer object fmt f_str object used format total row. none provided, display based layer formatting. count_missings Whether ignore named arguments passed `set_count_missing()` calculating counts total row. useful need exclude/include missing counts total row. Defaults TRUE meaning total row ignore values. sort_value value appear ordering column total rows. must numeric value.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_total_row.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add a Total row into a count summary. — add_total_row","text":"Totals calculated using grouping variables, including treat_var cols table level. variables included, grouping total application denominators becomes ambiguous. warned specifically percent included format. rectify , use set_denoms_by(), grouping add_total_row() updated accordingly. Note using add_total_row() set_pop_data(), call add_total_row() calling set_pop_data(), otherwise potential unexpected behaivior treatment groups.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_total_row.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a Total row into a count summary. — add_total_row","text":"","code":"# Load in Pipe library(magrittr) tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% add_total_row(f_str(\"xxxx\", n)) ) %>% build() #> # A tibble: 4 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 6 \" 2 ( 13.3%)\" \" 4 ( 33.3%)\" \" 1 ( 20.0… 1 2 #> 3 8 \"12 ( 80.0%)\" \" 0 ( 0.0%)\" \" 2 ( 40.0… 1 3 #> 4 Total \" 15\" \" 12\" \" 5\" 1 4"},{"path":"https://atorus-research.github.io/Tplyr/reference/append_metadata.html","id":null,"dir":"Reference","previous_headings":"","what":"Append the Tplyr table metadata dataframe — append_metadata","title":"Append the Tplyr table metadata dataframe — append_metadata","text":"append_metadata() allows user extend Tplyr metadata data frame user provided data. tables, Tplyr may able provided data, user may extend table summaries, statistics, etc. function allows user extend tplyr_table's metadata metadata content using custom data frames created using tplyr_meta object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/append_metadata.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Append the Tplyr table metadata dataframe — append_metadata","text":"","code":"append_metadata(t, meta)"},{"path":"https://atorus-research.github.io/Tplyr/reference/append_metadata.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Append the Tplyr table metadata dataframe — append_metadata","text":"t tplyr_table object meta dataframe fitting specifications details section function","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/append_metadata.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Append the Tplyr table metadata dataframe — append_metadata","text":"tplyr_table object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/append_metadata.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Append the Tplyr table metadata dataframe — append_metadata","text":"advanced feature Tplyr, ownership user make sure metadata data frame assembled properly. restrictions applied append_metadata() meta must column named row_id, values row_id duplicates row_id value already present Tplyr metadata dataframe. tplyr_meta() objects align constructed dataframes using row_id output dataset column name. , tplyr_meta() objects inserted data frame using list column.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/append_metadata.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Append the Tplyr table metadata dataframe — append_metadata","text":"","code":"t <- tplyr_table(mtcars, gear) %>% add_layer( group_desc(wt) ) t %>% build(metadata=TRUE) #> # A tibble: 6 × 7 #> row_id row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 d1_1 n \" 15\" \" 12\" \" 5\" 1 1 #> 2 d2_1 Mean (SD) \"3.8926 (0.83299)\" \"2.61… \"2.63… 1 2 #> 3 d3_1 Median \"3.7300\" \"2.70… \"2.77… 1 3 #> 4 d4_1 Q1, Q3 \"3.4500, 3.9575\" \"2.13… \"2.14… 1 4 #> 5 d5_1 Min, Max \"2.465, 5.424\" \"1.61… \"1.51… 1 5 #> 6 d6_1 Missing \" 0\" \" 0\" \" 0\" 1 6 m <- tibble::tibble( row_id = c('x1_1'), var1_3 = list(tplyr_meta(rlang::quos(a, b, c), rlang::quos(a==1, b==2, c==3))) ) append_metadata(t, m) #> *** tplyr_table *** #> Target (data.frame): #> \tName: mtcars #> \tRows: 32 #> \tColumns: 11 #> treat_var variable (quosure) #> \tgear #> header_n: 3 header groups #> treat_grps groupings (list) #> Table Columns (cols): #> where: TRUE #> Number of layer(s): 1 #> layer_output: 0"},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_conditional_format.html","id":null,"dir":"Reference","previous_headings":"","what":"Conditional reformatting of a pre-populated string of numbers — apply_conditional_format","title":"Conditional reformatting of a pre-populated string of numbers — apply_conditional_format","text":"function allows conditionally re-format string numbers based numeric value within string . selecting \"format group\", targeting specific number within string, user can establish condition upon provided replacement string can used. Either entire replacement can used replace entire string, replacement text can refill \"format group\" preserving original width alignment target string.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_conditional_format.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Conditional reformatting of a pre-populated string of numbers — apply_conditional_format","text":"","code":"apply_conditional_format( string, format_group, condition, replacement, full_string = FALSE )"},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_conditional_format.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Conditional reformatting of a pre-populated string of numbers — apply_conditional_format","text":"string Target character vector text may replaced format_group integer representing targeted numeric field within string, numbered left right condition expression, using variable name 'x' target variable within condition replacement string use replacement value full_string TRUE full string replaced, FALSE replacement done within format group","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_conditional_format.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Conditional reformatting of a pre-populated string of numbers — apply_conditional_format","text":"character vector","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_conditional_format.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Conditional reformatting of a pre-populated string of numbers — apply_conditional_format","text":"","code":"string <- c(\" 0 (0.0%)\", \" 8 (9.3%)\", \"78 (90.7%)\") apply_conditional_format(string, 2, x == 0, \" 0 \", full_string=TRUE) #> [1] \" 0 \" \" 8 (9.3%)\" \"78 (90.7%)\" apply_conditional_format(string, 2, x < 1, \"(<1%)\") #> [1] \" 0 (<1%)\" \" 8 (9.3%)\" \"78 (90.7%)\""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_formats.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply Format Strings outside of a Tplyr table — apply_formats","title":"Apply Format Strings outside of a Tplyr table — apply_formats","text":"f_str object Tplyr used drive formatting outputs strings within Tplyr table. function allows user use interface apply formatted string data frame within dplyr::mutate() context.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_formats.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply Format Strings outside of a Tplyr table — apply_formats","text":"","code":"apply_formats(format_string, ..., empty = c(.overall = \"\"))"},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_formats.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply Format Strings outside of a Tplyr table — apply_formats","text":"format_string desired display format. X's indicate digits. left, number x's indicates integer length. right, number x's controls decimal precision rounding. Variables inferred separation 'x' values decimal. ... variables formatted using format specified format_string. must numeric variables. empty string display numeric data available. Use single element character vector, element named '.overall' instead replace whole string.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_formats.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Apply Format Strings outside of a Tplyr table — apply_formats","text":"Character vector formatted values","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_formats.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Apply Format Strings outside of a Tplyr table — apply_formats","text":"Note auto-precision currently supported within apply_formats()","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_formats.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Apply Format Strings outside of a Tplyr table — apply_formats","text":"","code":"library(dplyr) mtcars %>% head() %>% mutate( fmt_example = apply_formats('xxx (xx.x)', hp, wt) ) #> mpg cyl disp hp drat wt qsec vs am gear carb #> Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4 #> Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4 #> Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1 #> Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1 #> Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2 #> Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1 #> fmt_example #> Mazda RX4 110 ( 2.6) #> Mazda RX4 Wag 110 ( 2.9) #> Datsun 710 93 ( 2.3) #> Hornet 4 Drive 110 ( 3.2) #> Hornet Sportabout 175 ( 3.4) #> Valiant 105 ( 3.5)"},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_row_masks.html","id":null,"dir":"Reference","previous_headings":"","what":"Replace repeating row label variables with blanks in preparation for display. — apply_row_masks","title":"Replace repeating row label variables with blanks in preparation for display. — apply_row_masks","text":"Depending display package used, row label values may need blanked repeating. gives data frame supporting table appearance grouping variables grouped together blocks. apply_row_masks work blanking value row_label variable current value equal value . Note - apply_row_masks assumes data frame already sorted therefore applied data frame final sort sequence.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_row_masks.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Replace repeating row label variables with blanks in preparation for display. — apply_row_masks","text":"","code":"apply_row_masks(dat, row_breaks = FALSE, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_row_masks.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Replace repeating row label variables with blanks in preparation for display. — apply_row_masks","text":"dat Data.frame / tibble mask repeating row_labels row_breaks Boolean - set TRUE insert row breaks ... Variable used determine row-breaks inserted. Breaks inserted group variables changes values. determined dataset order, sorting done prior using apply_row_masks. left empty, ord_layer_index used.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_row_masks.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Replace repeating row label variables with blanks in preparation for display. — apply_row_masks","text":"tibble blanked rows values repeating","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_row_masks.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Replace repeating row label variables with blanks in preparation for display. — apply_row_masks","text":"Additionally, apply_row_masks can add row breaks layer. Row breaks inserted blank rows. relies \"break \" variables (submitted via ...) constructed build still attached dataset. additional order variable attached named ord_break, output dataset sorted properly insert row breaks layers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/build.html","id":null,"dir":"Reference","previous_headings":"","what":"Trigger the execution of the tplyr_table — build","title":"Trigger the execution of the tplyr_table — build","text":"functions used assemble tplyr_table object layers trigger processing data. Rather, lazy execution style used allow construct table explicitly state data processing happen. build triggers event.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/build.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Trigger the execution of the tplyr_table — build","text":"","code":"build(x, metadata = FALSE)"},{"path":"https://atorus-research.github.io/Tplyr/reference/build.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Trigger the execution of the tplyr_table — build","text":"x tplyr_table object metadata Trigger build metadata. Defaults FALSE","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/build.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Trigger the execution of the tplyr_table — build","text":"executed tplyr_table","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/build.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Trigger the execution of the tplyr_table — build","text":"build command executed, data processing commences. pre-processing necessary within table environment takes place first. Next, layers begins executing. layers complete executing, output layer stacked resulting data frame. process complete, post-processing necessary within table environment takes place, final output can delivered. Metadata traceability information kept within layer environments, allows investigation source resulting datapoints. example, numeric data summaries performed maintained accessible within layer using get_numeric_data. `metadata` option build trigger construction traceability metadata constructed data frame. Essentially, every \"result\" Tplyr produces, Tplyr can also generate steps necessary obtain source data produced result input. information, see vignette(\"metadata\").","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/build.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Trigger the execution of the tplyr_table — build","text":"","code":"# Load in Pipe library(magrittr) tplyr_table(iris, Species) %>% add_layer( group_desc(Sepal.Length, by = \"Sepal Length\") ) %>% add_layer( group_desc(Sepal.Width, by = \"Sepal Width\") ) %>% build() #> # A tibble: 12 × 8 #> row_label1 row_label2 var1_setosa var1_versicolor var1_virginica #> #> 1 Sepal Length n \" 50\" \" 50\" \" 50\" #> 2 Sepal Length Mean (SD) \"5.01 (0.352)\" \"5.94 (0.516)\" \"6.59 (0.636)\" #> 3 Sepal Length Median \"5.00\" \"5.90\" \"6.50\" #> 4 Sepal Length Q1, Q3 \"4.80, 5.20\" \"5.60, 6.30\" \"6.23, 6.90\" #> 5 Sepal Length Min, Max \"4.3, 5.8\" \"4.9, 7.0\" \"4.9, 7.9\" #> 6 Sepal Length Missing \" 0\" \" 0\" \" 0\" #> 7 Sepal Width n \" 50\" \" 50\" \" 50\" #> 8 Sepal Width Mean (SD) \"3.43 (0.379)\" \"2.77 (0.314)\" \"2.97 (0.322)\" #> 9 Sepal Width Median \"3.40\" \"2.80\" \"3.00\" #> 10 Sepal Width Q1, Q3 \"3.20, 3.68\" \"2.52, 3.00\" \"2.80, 3.18\" #> 11 Sepal Width Min, Max \"2.3, 4.4\" \"2.0, 3.4\" \"2.2, 3.8\" #> 12 Sepal Width Missing \" 0\" \" 0\" \" 0\" #> # ℹ 3 more variables: ord_layer_index , ord_layer_1 , #> # ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/reference/by.html","id":null,"dir":"Reference","previous_headings":"","what":"Set or return by layer binding — get_by","title":"Set or return by layer binding — get_by","text":"Set return layer binding","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/by.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set or return by layer binding — get_by","text":"","code":"get_by(layer) set_by(layer, by)"},{"path":"https://atorus-research.github.io/Tplyr/reference/by.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set or return by layer binding — get_by","text":"layer tplyr_layer object string, variable name, list variable names supplied using dplyr::vars.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/by.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set or return by layer binding — get_by","text":"get_by, binding supplied layer. set_by modified layer environment.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/by.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set or return by layer binding — get_by","text":"","code":"# Load in pipe library(magrittr) iris$Species2 <- iris$Species lay <- tplyr_table(iris, Species) %>% group_count(Species) %>% set_by(vars(Species2, Sepal.Width))"},{"path":"https://atorus-research.github.io/Tplyr/reference/collapse_row_labels.html","id":null,"dir":"Reference","previous_headings":"","what":"Collapse row labels into a single column — collapse_row_labels","title":"Collapse row labels into a single column — collapse_row_labels","text":"generalized post processing function allows take groups variables collapse single column. Repeating values split separate rows, level nesting, specified indentation level can applied.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/collapse_row_labels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collapse row labels into a single column — collapse_row_labels","text":"","code":"collapse_row_labels(x, ..., indent = \" \", target_col = row_label)"},{"path":"https://atorus-research.github.io/Tplyr/reference/collapse_row_labels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collapse row labels into a single column — collapse_row_labels","text":"x Input data frame ... Row labels collapsed indent Indentation string used, multiplied indentation level target_col desired name output column containing collapsed row labels","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/collapse_row_labels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Collapse row labels into a single column — collapse_row_labels","text":"data.frame row labels collapsed single column","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/collapse_row_labels.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Collapse row labels into a single column — collapse_row_labels","text":"","code":"x <- tibble::tribble( ~row_label1, ~row_label2, ~row_label3, ~row_label4, ~var1, \"A\", \"C\", \"G\", \"M\", 1L, \"A\", \"C\", \"G\", \"N\", 2L, \"A\", \"C\", \"H\", \"O\", 3L, \"A\", \"D\", \"H\", \"P\", 4L, \"A\", \"D\", \"I\", \"Q\", 5L, \"A\", \"D\", \"I\", \"R\", 6L, \"B\", \"E\", \"J\", \"S\", 7L, \"B\", \"E\", \"J\", \"T\", 8L, \"B\", \"E\", \"K\", \"U\", 9L, \"B\", \"F\", \"K\", \"V\", 10L, \"B\", \"F\", \"L\", \"W\", 11L ) collapse_row_labels(x, row_label1, row_label2, row_label3, row_label4) #> # A tibble: 35 × 2 #> row_label var1 #> #> 1 \"A\" NA #> 2 \" C\" NA #> 3 \" G\" NA #> 4 \" M\" 1 #> 5 \" N\" 2 #> 6 \"A\" NA #> 7 \" C\" NA #> 8 \" H\" NA #> 9 \" O\" 3 #> 10 \"A\" NA #> # ℹ 25 more rows collapse_row_labels(x, row_label1, row_label2, row_label3) #> # A tibble: 19 × 3 #> row_label row_label4 var1 #> #> 1 \"A\" \"\" NA #> 2 \" C\" \"\" NA #> 3 \" G\" \"M\" 1 #> 4 \" G\" \"N\" 2 #> 5 \" H\" \"O\" 3 #> 6 \"A\" \"\" NA #> 7 \" D\" \"\" NA #> 8 \" H\" \"P\" 4 #> 9 \" I\" \"Q\" 5 #> 10 \" I\" \"R\" 6 #> 11 \"B\" \"\" NA #> 12 \" E\" \"\" NA #> 13 \" J\" \"S\" 7 #> 14 \" J\" \"T\" 8 #> 15 \" K\" \"U\" 9 #> 16 \"B\" \"\" NA #> 17 \" F\" \"\" NA #> 18 \" K\" \"V\" 10 #> 19 \" L\" \"W\" 11 collapse_row_labels(x, row_label1, row_label2, indent = \" \", target_col = rl) #> # A tibble: 13 × 4 #> rl row_label3 row_label4 var1 #> #> 1 \"A\" \"\" \"\" NA #> 2 \" C\" \"G\" \"M\" 1 #> 3 \" C\" \"G\" \"N\" 2 #> 4 \" C\" \"H\" \"O\" 3 #> 5 \" D\" \"H\" \"P\" 4 #> 6 \" D\" \"I\" \"Q\" 5 #> 7 \" D\" \"I\" \"R\" 6 #> 8 \"B\" \"\" \"\" NA #> 9 \" E\" \"J\" \"S\" 7 #> 10 \" E\" \"J\" \"T\" 8 #> 11 \" E\" \"K\" \"U\" 9 #> 12 \" F\" \"K\" \"V\" 10 #> 13 \" F\" \"L\" \"W\" 11"},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a f_str object — f_str","title":"Create a f_str object — f_str","text":"f_str objects intended used within function set_format_strings. f_str object carries information powers significant amount layer processing. format_string parameter capable controlling display data point decimal precision. variables provided ... control data points used populate string formatted output.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a f_str object — f_str","text":"","code":"f_str(format_string, ..., empty = c(.overall = \"\"))"},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a f_str object — f_str","text":"format_string desired display format. X's indicate digits. left, number x's indicates integer length. right, number x's controls decimal precision rounding. Variables inferred separation 'x' values decimal. ... variables formatted using format specified format_string. empty string display numeric data available. desc layers, unnamed character vector populate within provided format string, set width fitted numbers. Use single element character vector, element named '.overall' instead replace whole string.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a f_str object — f_str","text":"f_str object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create a f_str object — f_str","text":"Format strings one powerful components 'Tplyr'. Traditionally, converting numeric values strings presentation can consume good deal time. Values decimals need align rows, rounding trimming sometimes forgotten - can become tedious mess realistically important part analysis performed. 'Tplyr' makes process simple can, still allowing flexibility user. Tplyr provides manual automatic decimal precision formatting. display numbers resulting data frame controlled format_string parameter. manual precision, just like dummy values may presented mocks, integer decimal precision specified user providing string 'x's like numbers formatted. like 2 integers 3 decimal places, specify string 'xx.xxx'. 'Tplyr' work get numbers right place. take step , automatic decimal precision can also obtained based collected precision within data. creating tables results vary parameter, different results may call different degrees precision. use automatic precision, use single '' either integer decimal side. like use increased precision (.e. like mean collected precision +1), use '+1'. like integer decimal precision based data collected, can use format like '.' - collected+1 decimal precision, '.+1'. can mix match manual formats well, making format strings 'xx.+1'. want two numbers line, provide two sets x's. example, presenting value like \"mean (sd)\" - provide string 'xx.xx (xx.xxx)', perhaps '.+1 (.+2). Note able provide different integer lengths different decimal precision two values. format string independent relates format specified. described , using 'x' '', character within format string stay stationary. example, format string 'xx (xxx.x)', number may format '12 ( 34.5)'. left side parenthesis stays fixed. displays, may want parenthesis 'hug' number. Following example, allotting 3 spaces integer within parentheses, parentehsis shift right, making numbers appear '12 (34.5)'. Using f_str() can achieve using capital 'X' ''. example, format string 'xx (XXX.x)'. two rules using 'parenthesis hugging': Capital letters used integer side number character must precede capital letter, otherwise character 'hug' parameters f_str call specify values fill x's. f_str objects used slightly differently different layers. declaring format string within count layer, f_str() expects see values n distinct_n event distinct counts, pct distinct_pct event distinct percentages, total distinct_total denominator calculations. Note f_str() count layer '' '' based n counts, therefore make sense use percentages. descriptive statistic layers, f_str parameters refer names summaries performed, either built defaults, custom summaries declared using set_custom_summaries(). See set_format_strings() notes layers specific implementation. f_str() may also used outside Tplyr table. function apply_formats() allows apply f_str within context dplyr::mutate() generally vectorized function.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":"valid-f-str-variables-by-layer-type","dir":"Reference","previous_headings":"","what":"Valid f_str() Variables by Layer Type","title":"Create a f_str object — f_str","text":"Valid variables allowed within ... parameter f_str() differ layer type. Count layers n pct total distinct_n distinct_pct distinct_total Shift layers n pct total Desc layers n mean sd median var min max iqr q1 q3 missing Custom summaries created set_custom_summaries()","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a f_str object — f_str","text":"","code":"f_str(\"xx.x (xx.x)\", mean, sd) #> *** Format String *** #> xx.x (xx.x) #> *** vars, extracted formats, and settings *** #> mean formated as: xx.x #> \tinteger length: 2 #> \tdecimal length: 1 #> sd formated as: xx.x #> \tinteger length: 2 #> \tdecimal length: 1 #> Total Format Size: 11 f_str(\"a.a+1 (a.a+2)\", mean, sd) #> *** Format String *** #> a.a+1 (a.a+2) #> *** vars, extracted formats, and settings *** #> mean formated as: a.a+1 #> \tinteger length: 0 #> \tdecimal length: 1 #> sd formated as: a.a+2 #> \tinteger length: 0 #> \tdecimal length: 2 #> Total Format Size: 13 f_str(\"xx.a (xx.a+1)\", mean, sd) #> *** Format String *** #> xx.a (xx.a+1) #> *** vars, extracted formats, and settings *** #> mean formated as: xx.a #> \tinteger length: 2 #> \tdecimal length: 0 #> sd formated as: xx.a+1 #> \tinteger length: 2 #> \tdecimal length: 1 #> Total Format Size: 13 f_str(\"xx.x, xx.x, xx.x\", q1, median, q3) #> *** Format String *** #> xx.x, xx.x, xx.x #> *** vars, extracted formats, and settings *** #> q1 formated as: xx.x #> \tinteger length: 2 #> \tdecimal length: 1 #> median formated as: xx.x #> \tinteger length: 2 #> \tdecimal length: 1 #> q3 formated as: xx.x #> \tinteger length: 2 #> \tdecimal length: 1 #> Total Format Size: 16 f_str(\"xx (XXX.x%)\", n, pct) #> *** Format String *** #> xx (XXX.x%) #> *** vars, extracted formats, and settings *** #> n formated as: xx #> \tinteger length: 2 #> \tdecimal length: 0 #> pct formated as: (XXX.x #> \tinteger length: 4 #> \tdecimal length: 1 #> Total Format Size: 11 f_str(\"a.a+1 (A.a+2)\", mean, sd) #> *** Format String *** #> a.a+1 (A.a+2) #> *** vars, extracted formats, and settings *** #> mean formated as: a.a+1 #> \tinteger length: 0 #> \tdecimal length: 1 #> sd formated as: (A.a+2 #> \tinteger length: 0 #> \tdecimal length: 2 #> Total Format Size: 13"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_data_labels.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Data Labels — get_data_labels","title":"Get Data Labels — get_data_labels","text":"Get labels data sets included Tplyr.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_data_labels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Data Labels — get_data_labels","text":"","code":"get_data_labels(data)"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_data_labels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Data Labels — get_data_labels","text":"data Tplyr data set.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_data_labels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get Data Labels — get_data_labels","text":"data.frame columns `name` `label` containing names labels column.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_result.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract the result metadata of a Tplyr table — get_meta_result","title":"Extract the result metadata of a Tplyr table — get_meta_result","text":"Given row_id value result column, function return tplyr_meta object associated 'cell'.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_result.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract the result metadata of a Tplyr table — get_meta_result","text":"","code":"get_meta_result(x, row_id, column, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_result.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract the result metadata of a Tplyr table — get_meta_result","text":"x built Tplyr table dataframe row_id row_id value desired cell, provided character string column result column interest, provided character string ... additional arguments","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_result.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract the result metadata of a Tplyr table — get_meta_result","text":"tplyr_meta object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_result.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract the result metadata of a Tplyr table — get_meta_result","text":"Tplyr table built metadata=TRUE option specified, metadata assembled behind scenes provide traceability result cell derived. functions get_meta_result() get_meta_subset() allow access metadata using ID provided row_id column column name result like access. purpose row_id variable instead simple row index provide sort resistant reference originating column, output Tplyr table can sorted order metadata still easily accessible. tplyr_meta object provided list two elements - names filters. metadata contain every column target data.frame Tplyr table factored specified result cell, filters contains necessary filters subset data summarized create specified result cell. get_meta_subset() additionally provides parameter specify additional columns like include returned subset data frame.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_result.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract the result metadata of a Tplyr table — get_meta_result","text":"","code":"t <- tplyr_table(mtcars, cyl) %>% add_layer( group_desc(hp) ) dat <- t %>% build(metadata = TRUE) get_meta_result(t, 'd1_1', 'var1_4') #> tplyr_meta: 2 names, 3 filters #> Names: #> cyl, hp #> Filters: #> cyl == c(\"4\"), TRUE, TRUE m <- t$metadata dat <- t$target get_meta_result(t, 'd1_1', 'var1_4') #> tplyr_meta: 2 names, 3 filters #> Names: #> cyl, hp #> Filters: #> cyl == c(\"4\"), TRUE, TRUE"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_subset.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract the subset of data based on result metadata — get_meta_subset","title":"Extract the subset of data based on result metadata — get_meta_subset","text":"Given row_id value result column, function return subset data referenced tplyr_meta object associated 'cell', provides traceability tie result source.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_subset.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract the subset of data based on result metadata — get_meta_subset","text":"","code":"get_meta_subset(x, row_id, column, add_cols = vars(USUBJID), ...) # S3 method for data.frame get_meta_subset( x, row_id, column, add_cols = vars(USUBJID), target = NULL, pop_data = NULL, ... ) # S3 method for tplyr_table get_meta_subset(x, row_id, column, add_cols = vars(USUBJID), ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_subset.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract the subset of data based on result metadata — get_meta_subset","text":"x built Tplyr table dataframe row_id row_id value desired cell, provided character string column result column interest, provided character string add_cols Additional columns include subset data.frame output ... additional arguments target data frame subset (pulled Tplyr table) pop_data data frame subset anti-join (pulled Tplyr table)","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_subset.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract the subset of data based on result metadata — get_meta_subset","text":"data.frame","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_subset.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract the subset of data based on result metadata — get_meta_subset","text":"Tplyr table built metadata=TRUE option specified, metadata assembled behind scenes provide traceability result cell derived. functions get_meta_result() get_meta_subset() allow access metadata using ID provided row_id column column name result like access. purpose row_id variable instead simple row index provide sort resistant reference originating column, output Tplyr table can sorted order metadata still easily accessible. tplyr_meta object provided list two elements - names filters. metadata contain every column target data.frame Tplyr table factored specified result cell, filters contains necessary filters subset data summarized create specified result cell. get_meta_subset() additionally provides parameter specify additional columns like include returned subset data frame.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_subset.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract the subset of data based on result metadata — get_meta_subset","text":"","code":"t <- tplyr_table(mtcars, cyl) %>% add_layer( group_desc(hp) ) dat <- t %>% build(metadata = TRUE) get_meta_subset(t, 'd1_1', 'var1_4', add_cols = dplyr::vars(carb)) #> carb cyl hp #> Datsun 710 1 4 93 #> Merc 240D 2 4 62 #> Merc 230 2 4 95 #> Fiat 128 1 4 66 #> Honda Civic 2 4 52 #> Toyota Corolla 1 4 65 #> Toyota Corona 1 4 97 #> Fiat X1-9 1 4 66 #> Porsche 914-2 2 4 91 #> Lotus Europa 2 4 113 #> Volvo 142E 2 4 109 m <- t$metadata dat <- t$target get_meta_subset(t, 'd1_1', 'var1_4', add_cols = dplyr::vars(carb), target = target) #> carb cyl hp #> Datsun 710 1 4 93 #> Merc 240D 2 4 62 #> Merc 230 2 4 95 #> Fiat 128 1 4 66 #> Honda Civic 2 4 52 #> Toyota Corolla 1 4 65 #> Toyota Corona 1 4 97 #> Fiat X1-9 1 4 66 #> Porsche 914-2 2 4 91 #> Lotus Europa 2 4 113 #> Volvo 142E 2 4 109"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_metadata.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the metadata dataframe from a tplyr_table — get_metadata","title":"Get the metadata dataframe from a tplyr_table — get_metadata","text":"Pull metadata dataframe tplyr_table work directly","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_metadata.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the metadata dataframe from a tplyr_table — get_metadata","text":"","code":"get_metadata(t)"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_metadata.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the metadata dataframe from a tplyr_table — get_metadata","text":"t Tplyr table metadata built","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_metadata.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the metadata dataframe from a tplyr_table — get_metadata","text":"Tplyr metadata dataframe","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_metadata.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the metadata dataframe from a tplyr_table — get_metadata","text":"","code":"t <- tplyr_table(mtcars, gear) %>% add_layer( group_desc(wt) ) t %>% build(metadata=TRUE) #> # A tibble: 6 × 7 #> row_id row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 d1_1 n \" 15\" \" 12\" \" 5\" 1 1 #> 2 d2_1 Mean (SD) \"3.8926 (0.83299)\" \"2.61… \"2.63… 1 2 #> 3 d3_1 Median \"3.7300\" \"2.70… \"2.77… 1 3 #> 4 d4_1 Q1, Q3 \"3.4500, 3.9575\" \"2.13… \"2.14… 1 4 #> 5 d5_1 Min, Max \"2.465, 5.424\" \"1.61… \"1.51… 1 5 #> 6 d6_1 Missing \" 0\" \" 0\" \" 0\" 1 6 get_metadata(t) #> # A tibble: 6 × 5 #> row_id row_label1 var1_3 var1_4 var1_5 #> #> 1 d1_1 n #> 2 d2_1 Mean (SD) #> 3 d3_1 Median #> 4 d4_1 Q1, Q3 #> 5 d5_1 Min, Max #> 6 d6_1 Missing "},{"path":"https://atorus-research.github.io/Tplyr/reference/get_numeric_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Retrieve the numeric data from a tplyr objects — get_numeric_data","title":"Retrieve the numeric data from a tplyr objects — get_numeric_data","text":"get_numeric_data provides access un-formatted numeric data layers within tplyr_table, options allow extract distinct layers filter desired.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_numeric_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Retrieve the numeric data from a tplyr objects — get_numeric_data","text":"","code":"get_numeric_data(x, layer = NULL, where = TRUE, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_numeric_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Retrieve the numeric data from a tplyr objects — get_numeric_data","text":"x tplyr_table tplyr_layer object layer Layer name index select specifically Subset criteria passed dplyr::filter ... Additional arguments pass forward","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_numeric_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Retrieve the numeric data from a tplyr objects — get_numeric_data","text":"Numeric data Tplyr layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_numeric_data.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Retrieve the numeric data from a tplyr objects — get_numeric_data","text":"used tplyr_table object, method aggregate numeric data Tplyr layers. data returned user list data frames. data already processed (.e. build run), numeric data already available returned without reprocessing. Otherwise, numeric portion layer processed. Using layer parameters, data specific layer can extracted subset. clear layers given text names instead using layer index, numeric index works well.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_numeric_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Retrieve the numeric data from a tplyr objects — get_numeric_data","text":"","code":"# Load in pipe library(magrittr) t <- tplyr_table(mtcars, gear) %>% add_layer(name='drat', group_desc(drat) ) %>% add_layer(name='cyl', group_count(cyl) ) # Return a list of the numeric data frames get_numeric_data(t) #> $drat #> # A tibble: 27 × 4 #> summary_var gear stat value #> #> 1 drat 3 n 15 #> 2 drat 3 mean 3.13 #> 3 drat 3 sd 0.274 #> 4 drat 3 median 3.08 #> 5 drat 3 q1 3.04 #> 6 drat 3 q3 3.18 #> 7 drat 3 min 2.76 #> 8 drat 3 max 3.73 #> 9 drat 3 missing 0 #> 10 drat 4 n 12 #> # ℹ 17 more rows #> #> $cyl #> # A tibble: 9 × 6 #> gear summary_var n distinct_n total distinct_total #> #> 1 3 4 1 1 15 1 #> 2 3 6 2 1 15 1 #> 3 3 8 12 1 15 1 #> 4 4 4 8 1 12 1 #> 5 4 6 4 1 12 1 #> 6 4 8 0 0 12 1 #> 7 5 4 2 1 5 1 #> 8 5 6 1 1 5 1 #> 9 5 8 2 1 5 1 #> # Get the data from a specific layer get_numeric_data(t, layer='drat') #> # A tibble: 27 × 4 #> summary_var gear stat value #> #> 1 drat 3 n 15 #> 2 drat 3 mean 3.13 #> 3 drat 3 sd 0.274 #> 4 drat 3 median 3.08 #> 5 drat 3 q1 3.04 #> 6 drat 3 q3 3.18 #> 7 drat 3 min 2.76 #> 8 drat 3 max 3.73 #> 9 drat 3 missing 0 #> 10 drat 4 n 12 #> # ℹ 17 more rows get_numeric_data(t, layer=1) #> # A tibble: 27 × 4 #> summary_var gear stat value #> #> 1 drat 3 n 15 #> 2 drat 3 mean 3.13 #> 3 drat 3 sd 0.274 #> 4 drat 3 median 3.08 #> 5 drat 3 q1 3.04 #> 6 drat 3 q3 3.18 #> 7 drat 3 min 2.76 #> 8 drat 3 max 3.73 #> 9 drat 3 missing 0 #> 10 drat 4 n 12 #> # ℹ 17 more rows # Choose multiple layers by name or index get_numeric_data(t, layer=c('cyl', 'drat')) #> $cyl #> # A tibble: 9 × 6 #> gear summary_var n distinct_n total distinct_total #> #> 1 3 4 1 1 15 1 #> 2 3 6 2 1 15 1 #> 3 3 8 12 1 15 1 #> 4 4 4 8 1 12 1 #> 5 4 6 4 1 12 1 #> 6 4 8 0 0 12 1 #> 7 5 4 2 1 5 1 #> 8 5 6 1 1 5 1 #> 9 5 8 2 1 5 1 #> #> $drat #> # A tibble: 27 × 4 #> summary_var gear stat value #> #> 1 drat 3 n 15 #> 2 drat 3 mean 3.13 #> 3 drat 3 sd 0.274 #> 4 drat 3 median 3.08 #> 5 drat 3 q1 3.04 #> 6 drat 3 q3 3.18 #> 7 drat 3 min 2.76 #> 8 drat 3 max 3.73 #> 9 drat 3 missing 0 #> 10 drat 4 n 12 #> # ℹ 17 more rows #> get_numeric_data(t, layer=c(2, 1)) #> $cyl #> # A tibble: 9 × 6 #> gear summary_var n distinct_n total distinct_total #> #> 1 3 4 1 1 15 1 #> 2 3 6 2 1 15 1 #> 3 3 8 12 1 15 1 #> 4 4 4 8 1 12 1 #> 5 4 6 4 1 12 1 #> 6 4 8 0 0 12 1 #> 7 5 4 2 1 5 1 #> 8 5 6 1 1 5 1 #> 9 5 8 2 1 5 1 #> #> $drat #> # A tibble: 27 × 4 #> summary_var gear stat value #> #> 1 drat 3 n 15 #> 2 drat 3 mean 3.13 #> 3 drat 3 sd 0.274 #> 4 drat 3 median 3.08 #> 5 drat 3 q1 3.04 #> 6 drat 3 q3 3.18 #> 7 drat 3 min 2.76 #> 8 drat 3 max 3.73 #> 9 drat 3 missing 0 #> 10 drat 4 n 12 #> # ℹ 17 more rows #> # Get the data and filter it get_numeric_data(t, layer='drat', where = gear==3) #> # A tibble: 9 × 4 #> summary_var gear stat value #> #> 1 drat 3 n 15 #> 2 drat 3 mean 3.13 #> 3 drat 3 sd 0.274 #> 4 drat 3 median 3.08 #> 5 drat 3 q1 3.04 #> 6 drat 3 q3 3.18 #> 7 drat 3 min 2.76 #> 8 drat 3 max 3.73 #> 9 drat 3 missing 0"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_stats_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Get statistics data — get_stats_data","title":"Get statistics data — get_stats_data","text":"Like layer numeric data, Tplyr also stores numeric data produced statistics like risk difference. helper function gives access obtain data environment","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_stats_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get statistics data — get_stats_data","text":"","code":"get_stats_data(x, layer = NULL, statistic = NULL, where = TRUE, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_stats_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get statistics data — get_stats_data","text":"x tplyr_table tplyr_layer object layer Layer name index select specifically statistic Statistic name index select Subset criteria passed dplyr::filter ... Additional arguments passed dispatch","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_stats_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get statistics data — get_stats_data","text":"statistics data supplied layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_stats_data.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Get statistics data — get_stats_data","text":"used tplyr_table object, method aggregate numeric data Tplyr layers calculate statistics. data returned user list data frames. data already processed (.e. build run), numeric data already available statistic data simply returned. Otherwise, numeric portion layer processed. Using layer, , statistic parameters, data specific layer statistic can extracted subset, allowing directly access data interest. clear layers given text names instead using layer index, numeric index works well. just statistic specified, statistic collected returned list data frames, allowing grab, example, just risk difference statistics across layers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_stats_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get statistics data — get_stats_data","text":"","code":"library(magrittr) t <- tplyr_table(mtcars, gear) %>% add_layer(name='drat', group_desc(drat) ) %>% add_layer(name=\"cyl\", group_count(cyl) ) %>% add_layer(name=\"am\", group_count(am) %>% add_risk_diff(c('4', '3')) ) %>% add_layer(name=\"carb\", group_count(carb) %>% add_risk_diff(c('4', '3')) ) # Returns a list of lists, containing stats data from each layer get_stats_data(t) #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> $drat #> list() #> #> $cyl #> list() #> #> $am #> $am$riskdiff #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> #> #> $carb #> $carb$riskdiff #> # A tibble: 30 × 3 #> summary_var measure `4_3` #> #> 1 1 comp 0.333 #> 2 1 ref 0.2 #> 3 1 dif 0.133 #> 4 1 low -0.277 #> 5 1 high 0.543 #> 6 2 comp 0.333 #> 7 2 ref 0.267 #> 8 2 dif 0.0667 #> 9 2 low -0.348 #> 10 2 high 0.481 #> # ℹ 20 more rows #> #> # Returns just the riskdiff statistics from each layer - NULL # for layers without riskdiff get_stats_data(t, statistic=\"riskdiff\") #> $drat #> NULL #> #> $cyl #> NULL #> #> $am #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> #> $carb #> # A tibble: 30 × 3 #> summary_var measure `4_3` #> #> 1 1 comp 0.333 #> 2 1 ref 0.2 #> 3 1 dif 0.133 #> 4 1 low -0.277 #> 5 1 high 0.543 #> 6 2 comp 0.333 #> 7 2 ref 0.267 #> 8 2 dif 0.0667 #> 9 2 low -0.348 #> 10 2 high 0.481 #> # ℹ 20 more rows #> # Return the statistic data for just the \"am\" layer - a list get_stats_data(t, layer=\"am\") #> $riskdiff #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> get_stats_data(t, layer=3) #> $riskdiff #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> # Return the statistic data for just the \"am\" and \"cyl\", layer - a # list of lists get_stats_data(t, layer=c(\"am\", \"cyl\")) #> $am #> $am$riskdiff #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> #> #> $cyl #> list() #> get_stats_data(t, layer=c(3, 2)) #> $am #> $am$riskdiff #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> #> #> $cyl #> list() #> # Return just the statistic data for \"am\" and \"cyl\" - a list get_stats_data(t, layer=c(\"am\", \"cyl\"), statistic=\"riskdiff\") #> $am #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> #> $cyl #> NULL #> get_stats_data(t, layer=c(3, 2), statistic=\"riskdiff\") #> $am #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> #> $cyl #> NULL #> # Return the riskdiff for the \"am\" layer - a data frame get_stats_data(t, layer=\"am\", statistic=\"riskdiff\") #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 # Return and filter the riskdiff for the am layer - a data frame get_stats_data(t, layer=\"am\", statistic=\"riskdiff\", where = summary_var==1) #> # A tibble: 5 × 3 #> summary_var measure `4_3` #> #> 1 1 comp 0.667 #> 2 1 ref 0 #> 3 1 dif 0.667 #> 4 1 low 0.325 #> 5 1 high 1"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_tplyr_regex.html","id":null,"dir":"Reference","previous_headings":"","what":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","title":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","text":"function allows extract important regular expressions used inside Tplyr.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_tplyr_regex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","text":"","code":"get_tplyr_regex(rx = c(\"format_string\", \"format_group\"))"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_tplyr_regex.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","text":"rx character string either value 'format_string' 'format_group'","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_tplyr_regex.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","text":"regular expression object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_tplyr_regex.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","text":"two important regular expressions used within Tplyr. format_string expression expression parse format strings. used make sense strings like 'xx (XX.x%)' '+1 (.+2)' inferring user specifying number formatting. 'format_group' regex opposite , given string numbers, ' 5 (34%) [9]' return separate segments numbers broken format groups, example ' 5', '(34%)', '[9]'.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_tplyr_regex.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","text":"","code":"get_tplyr_regex('format_string') #> [1] \"(a(\\\\+\\\\d+)?|(\\\\S+)A(\\\\+\\\\d+)?|(\\\\S+)X+|x+)(\\\\.([A|a](\\\\+\\\\d+)?|[X|x]+)?)?\" #> attr(,\"options\") #> attr(,\"options\")$case_insensitive #> [1] FALSE #> #> attr(,\"options\")$comments #> [1] FALSE #> #> attr(,\"options\")$dotall #> [1] FALSE #> #> attr(,\"options\")$multiline #> [1] FALSE #> #> attr(,\"class\") #> [1] \"stringr_regex\" \"stringr_pattern\" \"character\" get_tplyr_regex('format_group') #> [1] \"[^\\\\s\\\\d]*\\\\s*(\\\\-?\\\\d+(\\\\.\\\\d+)?)\\\\S*\" #> attr(,\"options\") #> attr(,\"options\")$case_insensitive #> [1] FALSE #> #> attr(,\"options\")$comments #> [1] FALSE #> #> attr(,\"options\")$dotall #> [1] FALSE #> #> attr(,\"options\")$multiline #> [1] FALSE #> #> attr(,\"class\") #> [1] \"stringr_regex\" \"stringr_pattern\" \"character\""},{"path":"https://atorus-research.github.io/Tplyr/reference/header_n.html","id":null,"dir":"Reference","previous_headings":"","what":"Return or set header_n binding — header_n","title":"Return or set header_n binding — header_n","text":"`header_n()` functions can used automatically pull header_n derivations table change future use.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/header_n.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return or set header_n binding — header_n","text":"","code":"header_n(table) header_n(x) <- value set_header_n(table, value)"},{"path":"https://atorus-research.github.io/Tplyr/reference/header_n.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return or set header_n binding — header_n","text":"table tplyr_table object x tplyr_table object value data.frame columns treatment variable, column variabes, variable counts named 'n'. header_n data.frame columns treatment variable, column variabes, variable counts named 'n'.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/header_n.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return or set header_n binding — header_n","text":"tplyr_header_n header_n binding tplyr_table object. tplyr_header_n<- set_tplyr_header_n modified object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/header_n.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Return or set header_n binding — header_n","text":"`header_n` object created Tplyr table built intended used `add_column_headers()` function displaying table level population totals. methods intended used calling population totals calculated Tplyr, overwrite user chooses . need change header Ns appear table headers, say know working subset data represent totals, can replace data used `set_header_n()`.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/header_n.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return or set header_n binding — header_n","text":"","code":"tab <- tplyr_table(mtcars, gear) header_n(tab) <- data.frame( gear = c(3, 4, 5), n = c(10, 15, 45) )"},{"path":"https://atorus-research.github.io/Tplyr/reference/keep_levels.html","id":null,"dir":"Reference","previous_headings":"","what":"Select levels to keep in a count layer — keep_levels","title":"Select levels to keep in a count layer — keep_levels","text":"certain cases want layer include certain values factor. `keep_levels()` function allows pass character values included layer. others ignored. **NOTE: Denominator calculation unaffected function, see examples include logic percentages'**","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/keep_levels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select levels to keep in a count layer — keep_levels","text":"","code":"keep_levels(e, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/keep_levels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select levels to keep in a count layer — keep_levels","text":"e count_layer object ... Character values count int layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/keep_levels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select levels to keep in a count layer — keep_levels","text":"modified Tplyr layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/keep_levels.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select levels to keep in a count layer — keep_levels","text":"","code":"library(dplyr) mtcars <- mtcars %>% mutate_all(as.character) t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% keep_levels(\"4\", \"8\") %>% set_denom_where(cyl %in% c(\"4\", \"8\")) ) %>% build()"},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_attachment.html","id":null,"dir":"Reference","previous_headings":"","what":"Attach a layer to a tplyr_table object — add_layer","title":"Attach a layer to a tplyr_table object — add_layer","text":"add_layer attaches tplyr_layer tplyr_table object. allows tidy style programming (using magrittr piping, .e. %>%) secondary advantage - construction layer object may consist series piped functions . Tplyr encourages user view construction table series \"layers\". construction layers isolated independent one another - layers children table . add_layer isolates construction individual layer allows user construct layer insert back parent. syntax intuitive allows tidy piping. Simply pipe current table object , write code construct layer within layer parameter. add_layers another approach attaching layers tplyr_table. Instead constructing entire table , add_layers allows construct layers different objects. layers can attached tplyr_table . add_layer add_layers additionally allow name layers attach . helpful using functions like get_numeric_data get_stats_data can access information layer directly. add_layer name parameter, layers can named add_layers submitting layer named argument.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_attachment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Attach a layer to a tplyr_table object — add_layer","text":"","code":"add_layer(parent, layer, name = NULL) add_layers(parent, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_attachment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Attach a layer to a tplyr_table object — add_layer","text":"parent tplyr_table tplyr_layer/tplyr_subgroup_layer object layer layer construction function associated modifier functions name name provide layer table layers container ... Layers added","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_attachment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Attach a layer to a tplyr_table object — add_layer","text":"tplyr_table tplyr_layer/tplyr_subgroup_layer new layer inserted layer binding","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_attachment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Attach a layer to a tplyr_table object — add_layer","text":"","code":"# Load in pipe library(magrittr) ## Single layer t <- tplyr_table(mtcars, cyl) %>% add_layer( group_desc(target_var=mpg) ) ## Single layer with name t <- tplyr_table(mtcars, cyl) %>% add_layer(name='mpg', group_desc(target_var=mpg) ) # Using add_layers t <- tplyr_table(mtcars, cyl) l1 <- group_desc(t, target_var=mpg) l2 <- group_count(t, target_var=cyl) t <- add_layers(t, l1, 'cyl' = l2)"},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_constructors.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","title":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","text":"family functions specifies type summary performed within layer. count layers used create summary counts discrete variable. desc layers create summary statistics, shift layers summaries counts different changes states. See \"details\" section information.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_constructors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","text":"","code":"group_count(parent, target_var, by = vars(), where = TRUE, ...) group_desc(parent, target_var, by = vars(), where = TRUE, ...) group_shift(parent, target_var, by = vars(), where = TRUE, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_constructors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","text":"parent Required. parent environment layer. must tplyr_table object layer contained within. target_var Symbol. Required, variable name(s) summary performed. Must variable within target dataset. Enter unquoted - .e. target_var = AEBODSYS. may also provide multiple variables vars. string, variable name, list variable names supplied using vars Call. Filter logic used subset target data performing summary. ... Additional arguments pass forward","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_constructors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","text":"tplyr_layer environment child specified parent. environment contains object listed . tplyr_layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_constructors.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","text":"Count Layers Count layers allow create summaries based counting values variable. Additionally, layer allows create n (%) summaries also summarizing proportion instances value occurs compared denominator. Count layers also capable producing counts nested relationships. example, want produce counts overall outside group, subgroup counts within group, can specify target variable vars(OutsideVariable, InsideVariable). allows tables like Adverse Events want see Preferred Terms within Body Systems, one layer. control denominators available using function set_denoms_by distinct counts can set using set_distinct_by Descriptive Statistics Layers Descriptive statistics layers perform summaries continuous variables. number summaries built Tplyr already can perform, including n, mean, median, standard deviation, variance, min, max, inter-quartile range, Q1, Q3, missing value counts. available summaries, default presentation descriptive statistic layer output 'n', 'Mean (SD)', 'Median', 'Q1, Q3', 'Min, Max', 'Missing'. can change summaries using set_format_strings, can also add summaries using set_custom_summaries. allows implement additional summary statistics want presented. Shift Layers shift layer displays endpoint's 'shift' throughout duration study. abstraction count layer, however provided interface efficient intuitive. Targets passed named symbols using dplyr::vars. Generally baseline passed name 'row' shift passed name 'column'. counts (n) percentages (pct) supported can specified set_format_strings function. allow flexibility defining percentages, can define denominator using set_denoms_by function. function takes variable names uses determine denominator counts.","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_constructors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","text":"","code":"# Load in pipe library(magrittr) t <- tplyr_table(iris, Species) %>% add_layer( group_desc(target_var=Sepal.Width) ) t <- tplyr_table(iris, Species) %>% add_layer( group_desc(target_var=Sepal.Width) ) t <- tplyr_table(mtcars, am) %>% add_layer( group_shift(vars(row=gear, column=carb), by=cyl) )"},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_templates.html","id":null,"dir":"Reference","previous_headings":"","what":"Create, view, extract, remove, and use Tplyr layer templates — new_layer_template","title":"Create, view, extract, remove, and use Tplyr layer templates — new_layer_template","text":"several scenarios layer template may useful. tables, like demographics tables, may many layers essentially look . Categorical variables count layer settings, continuous variables desc layer settings. template allows user build settings per layer, reference template Tplyr table actually built.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_templates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create, view, extract, remove, and use Tplyr layer templates — new_layer_template","text":"","code":"new_layer_template(name, template) remove_layer_template(name) get_layer_template(name) get_layer_templates() use_template(name, ..., add_params = NULL)"},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_templates.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create, view, extract, remove, and use Tplyr layer templates — new_layer_template","text":"name Template name template Template layer syntax, starting layer constructor group_count|desc|shift. function called ellipsis argument (.e. group_count(...)). ... Arguments passed directly layer constructor, matching target, , parameters. add_params Additional parameters passed layer modifier functions. arguments specified template within curly brackets {param}. Supply named list, element name parameter.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_templates.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create, view, extract, remove, and use Tplyr layer templates — new_layer_template","text":"suite functions allows user create use layer templates. Layer templates allow user pre-build reuse entire layer configuration, layer constructor modifying functions. Furthermore, users can specify parameters may want interchangeable. Additionally, layer templates extensible, template can use extended additional layer modifying functions. Layers created using new_layer_template(). use layer, use function use_template() place group_count|desc|shift(). want view specific template, use get_layer_template(). want view templates, use get_layer_templates(). remove layer template use remove_layer_template(). Layer templates stored option tplyr.layer_templates, user access directly instead use Tplyr supplied functions. providing template layer syntax, layer must start layer constructor. one function group_count(), group_desc(), group_shift(). Instead passing arguments function, templates specified using ellipsis constructor, .e. group_count(...). required, template built user supplies arguments via use_template() use_template() takes group_count|desc|shift() arguments default. user specified additional arguments template, provided list throught argument add_params. Provide arguments exactly normal layer. creating template, parameters can specified using curly brackets. See examples details.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_templates.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create, view, extract, remove, and use Tplyr layer templates — new_layer_template","text":"","code":"op <- options() new_layer_template( \"example_template\", group_count(...) %>% set_format_strings(f_str('xx (xx%)', n, pct)) ) get_layer_templates() #> $example_template #> Template name: example_template #> Template parameters: None #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx%)\", n, pct)) #> } #> get_layer_template(\"example_template\") #> Template name: example_template #> Template parameters: None #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx%)\", n, pct)) #> } tplyr_table(mtcars, vs) %>% add_layer( use_template(\"example_template\", gear) ) %>% build() #> # A tibble: 3 × 5 #> row_label1 var1_0 var1_1 ord_layer_index ord_layer_1 #> #> 1 3 \"12 (67%)\" \" 3 (21%)\" 1 1 #> 2 4 \" 2 (11%)\" \"10 (71%)\" 1 2 #> 3 5 \" 4 (22%)\" \" 1 ( 7%)\" 1 3 remove_layer_template(\"example_template\") new_layer_template( \"example_template\", group_count(...) %>% set_format_strings(f_str('xx (xx%)', n, pct)) %>% set_order_count_method({sort_meth}) %>% set_ordering_cols({sort_cols}) ) get_layer_template(\"example_template\") #> Template name: example_template #> Template parameters: sort_meth, sort_cols #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx%)\", n, pct)) %>% set_order_count_method({ #> sort_meth #> }) %>% set_ordering_cols({ #> sort_cols #> }) #> } tplyr_table(mtcars, vs) %>% add_layer( use_template(\"example_template\", gear, add_params = list( sort_meth = \"bycount\", sort_cols = `1` )) ) %>% build() #> # A tibble: 3 × 5 #> row_label1 var1_0 var1_1 ord_layer_index ord_layer_1 #> #> 1 3 \"12 (67%)\" \" 3 (21%)\" 1 3 #> 2 4 \" 2 (11%)\" \"10 (71%)\" 1 10 #> 3 5 \" 4 (22%)\" \" 1 ( 7%)\" 1 1 remove_layer_template(\"example_template\") options(op)"},{"path":"https://atorus-research.github.io/Tplyr/reference/metadata_additions.html","id":null,"dir":"Reference","previous_headings":"","what":"Add variables to a tplyr_meta object — add_variables","title":"Add variables to a tplyr_meta object — add_variables","text":"Add additional variable names tplyr_meta() object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/metadata_additions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add variables to a tplyr_meta object — add_variables","text":"","code":"add_variables(meta, names) add_filters(meta, filters)"},{"path":"https://atorus-research.github.io/Tplyr/reference/metadata_additions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add variables to a tplyr_meta object — add_variables","text":"meta tplyr_meta object names list names, providing variable names interest. Provide list quosures using rlang::quos() filters list symbols, providing variable names interest. Provide list quosures using `rlang::quos()`","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/metadata_additions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add variables to a tplyr_meta object — add_variables","text":"tplyr_meta object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/metadata_additions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add variables to a tplyr_meta object — add_variables","text":"","code":"m <- tplyr_meta() m <- add_variables(m, rlang::quos(a, b, c)) m <- add_filters(m, rlang::quos(a==1, b==2, c==3)) m #> tplyr_meta: 3 names, 3 filters #> Names: #> a, b, c #> Filters: #> a == 1, b == 2, c == 3"},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the ordering logic for the count layer — set_order_count_method","title":"Set the ordering logic for the count layer — set_order_count_method","text":"sorting table can greatly vary depending situation hand. count layers, creating tables like adverse event summaries, may wish order table descending occurrence within particular treatment group. situations, AEs special interest, subject disposition, may specific order wish display values. Tplyr offers solutions situations. Instead allowing specify custom sort order, Tplyr instead provides order variables can used sort table data summarized. Tplyr default order table returned, order variables always persist. allows use powerful sorting functions like arrange get desired order, double programming situations, helps validator understand achieved particular sort order discrepancies may coming . creating order variables layer, '' variable Tplyr search N version variable (.e. VISIT <-> VISITN, PARAM <-> PARAMN). available, variable used sorting. available, Tplyr created new ordered factor version variable use alphanumeric sorting. allows user control custom sorting order leaving existing N variable dataset exists, create one based order wish sort - custom functions Tplyr required. Ordering results things start differ. Different situations call different methods. Descriptive statistics layers keep simple - order input formats using set_format_strings order results appear (order variable added). count layers, Tplyr offers three solutions: N version target variable, use . , target variable factor, use factor orders. Finally, can use specific data point results columns. result column can often multiple data points, n counts, percent, distinct n, distinct percent. Tplyr allows choose values used creating order columns specified result column (.e. based treat_var cols arguments). See 'Sorting Table' section information. Shift layers sort similarly count layers, order row shift variable, use ordered factor.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the ordering logic for the count layer — set_order_count_method","text":"","code":"set_order_count_method(e, order_count_method, break_ties = NULL) set_ordering_cols(e, ...) set_result_order_var(e, result_order_var)"},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the ordering logic for the count layer — set_order_count_method","text":"e count_layer object order_count_method logic determining rows final layer output indexed. Options 'bycount', 'byfactor', 'byvarn'. break_ties certain cases, 'bycount' sort result conflicts counts unique. break_ties add decimal sorting column resolve conflicts. character value 'asc' add decimal based alphabetical sorting. 'desc' sort descending case intention. ... Unquoted variables used select columns whose values extracted ordering. result_order_var numeric value ordering done . can either n, distinct_n, pct, distinct_pct. Due evaluation layer can add value actually evaluated, happens error ordering.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the ordering logic for the count layer — set_order_count_method","text":"Returns modified layer object. 'ord_' columns added build process.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"sorting-a-table","dir":"Reference","previous_headings":"","what":"Sorting a Table","title":"Set the ordering logic for the count layer — set_order_count_method","text":"table built, output several ordering(ord_) columns appended. first represents layer index. index determined order layer added table. Following indices variables target variable. variables ordered based : `` variable factor target dataset variable factor, N variable (.e. VISIT -> VISITN, TRT -> TRTN) variable factor target dataset, coerced one ordered alphabetically. target variable ordered depending type layer. See .","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"ordering-a-count-layer","dir":"Reference","previous_headings":"","what":"Ordering a Count Layer","title":"Set the ordering logic for the count layer — set_order_count_method","text":"many ways order count layer depending preferences table programmer. Tplyr supports sorting descending amount column table, sorting N variable, sorting custom order. can set using `set_order_count_method` function. Sorting numeric count selected numeric value selected column indexed based descending numeric value. numeric value extracted defaults 'n' can changed `set_result_order_var`. column selected sorting defaults first value treatment group variable. arguments passed 'cols' argument table must specified `set_ordering_columns`. Sorting 'varn' variable treatment variable N variable. can indexed variable. Sorting factor(Default) factor found target variable target dataset used order, factor found coerced factor sorted alphabetically. Sorting nested count layer two variables targeted count layer, two methods can passed `set_order_count`. two passed, first used sort blocks, second used sort \"inside\" blocks. one method passed, used sort .","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"ordering-a-desc-layer","dir":"Reference","previous_headings":"","what":"Ordering a Desc Layer","title":"Set the ordering logic for the count layer — set_order_count_method","text":"order desc layer mostly set object construction. variables resolved index logic count layers. target variable ordered based format strings used layer created.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the ordering logic for the count layer — set_order_count_method","text":"","code":"library(dplyr) # Default sorting by factor t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) ) build(t) #> # A tibble: 3 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 6 \" 2 ( 13.3%)\" \" 4 ( 33.3%)\" \" 1 ( 20.0… 1 2 #> 3 8 \"12 ( 80.0%)\" \" 0 ( 0.0%)\" \" 2 ( 40.0… 1 3 # Sorting by N mtcars$cylN <- mtcars$cyl t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% set_order_count_method(\"byvarn\") ) # Sorting by row count t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% set_order_count_method(\"bycount\") %>% # Orders based on the 6 gear group set_ordering_cols(6) ) # Sorting by row count by percentages t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% set_order_count_method(\"bycount\") %>% set_result_order_var(pct) ) # Sorting when you have column arguments in the table t <- tplyr_table(mtcars, gear, cols = vs) %>% add_layer( group_count(cyl) %>% # Uses the fourth gear group and the 0 vs group in ordering set_ordering_cols(4, 0) ) # Using a custom factor to order mtcars$cyl <- factor(mtcars$cyl, c(6, 4, 8)) t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% # This is the default but can be used to change the setting if it is #set at the table level. set_order_count_method(\"byfactor\") )"},{"path":"https://atorus-research.github.io/Tplyr/reference/pipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Pipe operator — %>%","title":"Pipe operator — %>%","text":"See magrittr::%>% details.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pipe operator — %>%","text":"","code":"lhs %>% rhs"},{"path":"https://atorus-research.github.io/Tplyr/reference/pipe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pipe operator — %>%","text":"lhs value magrittr placeholder. rhs function call using magrittr semantics.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pipe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Pipe operator — %>%","text":"result calling `rhs(lhs)`.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Return or set population data bindings — pop_data","title":"Return or set population data bindings — pop_data","text":"population data used gather information may available target dataset. example, missing treatment groups, population N counts, proper N counts denominators provided population dataset. population dataset defaults target dataset unless otherwise specified using set_pop_data.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return or set population data bindings — pop_data","text":"","code":"pop_data(table) pop_data(x) <- value set_pop_data(table, pop_data)"},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return or set population data bindings — pop_data","text":"table tplyr_table object x tplyr_table object value data.frame population level information pop_data data.frame population level information","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return or set population data bindings — pop_data","text":"tplyr_pop_data pop_data binding tplyr_table object. tplyr_pop_data<- nothing returned, pop_data binding set silently. set_tplyr_pop_data modified object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return or set population data bindings — pop_data","text":"","code":"tab <- tplyr_table(iris, Species) pop_data(tab) <- mtcars tab <- tplyr_table(iris, Species) %>% set_pop_data(mtcars)"},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_treat_var.html","id":null,"dir":"Reference","previous_headings":"","what":"Return or set pop_treat_var binding — pop_treat_var","title":"Return or set pop_treat_var binding — pop_treat_var","text":"treatment variable used target data may different variable within population dataset. set_pop_treat_var allows change .","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_treat_var.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return or set pop_treat_var binding — pop_treat_var","text":"","code":"pop_treat_var(table) set_pop_treat_var(table, pop_treat_var)"},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_treat_var.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return or set pop_treat_var binding — pop_treat_var","text":"table tplyr_table object pop_treat_var Variable containing treatment group assignments within pop_data binding. Supply unquoted.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_treat_var.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return or set pop_treat_var binding — pop_treat_var","text":"tplyr_pop_treat_var pop_treat_var binding tplyr_table object. set_tplyr_pop_treat_var modified object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_treat_var.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return or set pop_treat_var binding — pop_treat_var","text":"","code":"tab <- tplyr_table(iris, Species) pop_data(tab) <- mtcars set_pop_treat_var(tab, mpg) #> *** tplyr_table *** #> Target (data.frame): #> \tName: iris #> \tRows: 150 #> \tColumns: 5 #> pop_data (data.frame) #> \tName: value #> \tRows: 32 #> \tColumns: 11 #> treat_var variable (quosure) #> \tSpeciespop_treat_var variable (quosure) #> \tmpg #> #> header_n: header groups #> treat_grps groupings (list) #> Table Columns (cols): #> where: TRUE #> Number of layer(s): 0 #> layer_output: 0"},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_by.html","id":null,"dir":"Reference","previous_headings":"","what":"Set or return precision_by layer binding — get_precision_by","title":"Set or return precision_by layer binding — get_precision_by","text":"precision_by variables used collect integer decimal precision auto-precision used. variables used group input data identify maximum precision available within dataset group. precision_by variables must subset variables","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_by.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set or return precision_by layer binding — get_precision_by","text":"","code":"get_precision_by(layer) set_precision_by(layer, precision_by)"},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_by.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set or return precision_by layer binding — get_precision_by","text":"layer tplyr_layer object precision_by string, variable name, list variable names supplied using dplyr::vars.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_by.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set or return precision_by layer binding — get_precision_by","text":"get_precision_by, precision_by binding supplied layer. set_precision_by modified layer environment.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_by.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set or return precision_by layer binding — get_precision_by","text":"","code":"# Load in pipe library(magrittr) lay <- tplyr_table(mtcars, gear) %>% add_layer( group_desc(mpg, by=vars(carb, am)) %>% set_precision_by(carb) )"},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_on.html","id":null,"dir":"Reference","previous_headings":"","what":"Set or return precision_on layer binding — get_precision_on","title":"Set or return precision_on layer binding — get_precision_on","text":"precision_on variable variable used establish numeric precision. variable must included list target_var variables.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_on.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set or return precision_on layer binding — get_precision_on","text":"","code":"get_precision_on(layer) set_precision_on(layer, precision_on)"},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_on.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set or return precision_on layer binding — get_precision_on","text":"layer tplyr_layer object precision_on string, variable name, list variable names supplied using dplyr::vars.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_on.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set or return precision_on layer binding — get_precision_on","text":"get_precision_on, precision_on binding supplied layer. set_precision_on modified layer environment.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_on.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set or return precision_on layer binding — get_precision_on","text":"","code":"# Load in pipe library(magrittr) lay <- tplyr_table(mtcars, gear) %>% add_layer( group_desc(vars(mpg, disp), by=vars(carb, am)) %>% set_precision_on(disp) )"},{"path":"https://atorus-research.github.io/Tplyr/reference/process_formatting.html","id":null,"dir":"Reference","previous_headings":"","what":"Process layers to get formatted and pivoted tables. — process_formatting","title":"Process layers to get formatted and pivoted tables. — process_formatting","text":"internal method, exported support S3 dispatch. intended direct use user.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_formatting.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process layers to get formatted and pivoted tables. — process_formatting","text":"","code":"process_formatting(x, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/process_formatting.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process layers to get formatted and pivoted tables. — process_formatting","text":"x tplyr_layer object ... arguments passed dispatch","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_formatting.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process layers to get formatted and pivoted tables. — process_formatting","text":"formatted_table object bound layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_metadata.html","id":null,"dir":"Reference","previous_headings":"","what":"Process layers to get metadata tables — process_metadata","title":"Process layers to get metadata tables — process_metadata","text":"internal method, exported support S3 dispatch. intended direct use user.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_metadata.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process layers to get metadata tables — process_metadata","text":"","code":"process_metadata(x, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/process_metadata.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process layers to get metadata tables — process_metadata","text":"x tplyr_layer object ... arguments passed dispatch","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_metadata.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process layers to get metadata tables — process_metadata","text":"formatted_meta object bound layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Process a tplyr_statistic object — process_statistic_data","title":"Process a tplyr_statistic object — process_statistic_data","text":"internal function meant use externally, must exported. Use caution.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process a tplyr_statistic object — process_statistic_data","text":"","code":"process_statistic_data(x, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process a tplyr_statistic object — process_statistic_data","text":"x tplyr_statistic environment ... Additional pass parameters","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process a tplyr_statistic object — process_statistic_data","text":"Numeric statistc data tplyr statistc","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_formatting.html","id":null,"dir":"Reference","previous_headings":"","what":"Process string formatting on a tplyr_statistic object — process_statistic_formatting","title":"Process string formatting on a tplyr_statistic object — process_statistic_formatting","text":"internal function meant use externally, must exported. Use caution.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_formatting.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process string formatting on a tplyr_statistic object — process_statistic_formatting","text":"","code":"process_statistic_formatting(x, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_formatting.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process string formatting on a tplyr_statistic object — process_statistic_formatting","text":"x tplyr_statistic environment ... Additional pass parameters","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_formatting.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process string formatting on a tplyr_statistic object — process_statistic_formatting","text":"Formatted tplyr_statistic data","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_summaries.html","id":null,"dir":"Reference","previous_headings":"","what":"Process layers to get numeric results of layer — process_summaries","title":"Process layers to get numeric results of layer — process_summaries","text":"internal method, exported support S3 dispatch. intended direct use user.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_summaries.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process layers to get numeric results of layer — process_summaries","text":"","code":"process_summaries(x, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/process_summaries.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process layers to get numeric results of layer — process_summaries","text":"x tplyr_layer object ... arguments passed dispatch","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_summaries.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process layers to get numeric results of layer — process_summaries","text":"tplyr_layer object 'built_table' binding","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/replace_leading_whitespace.html","id":null,"dir":"Reference","previous_headings":"","what":"Reformat strings with leading whitespace for HTML — replace_leading_whitespace","title":"Reformat strings with leading whitespace for HTML — replace_leading_whitespace","text":"Reformat strings leading whitespace HTML","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/replace_leading_whitespace.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reformat strings with leading whitespace for HTML — replace_leading_whitespace","text":"","code":"replace_leading_whitespace(x, tab_width = 4)"},{"path":"https://atorus-research.github.io/Tplyr/reference/replace_leading_whitespace.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reformat strings with leading whitespace for HTML — replace_leading_whitespace","text":"x Target string tab_width Number spaces compensate tabs","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/replace_leading_whitespace.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reformat strings with leading whitespace for HTML — replace_leading_whitespace","text":"String   replaced leading whitespace","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/replace_leading_whitespace.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Reformat strings with leading whitespace for HTML — replace_leading_whitespace","text":"","code":"x <- c(\" Hello there\", \" Goodbye Friend \", \"\\tNice to meet you\", \" \\t What are you up to? \\t \\t \") replace_leading_whitespace(x) #> [1] \" Hello there\" #> [2] \"  Goodbye Friend \" #> [3] \"    Nice to meet you\" #> [4] \"       What are you up to? \\t \\t \" replace_leading_whitespace(x, tab=2) #> [1] \" Hello there\" #> [2] \"  Goodbye Friend \" #> [3] \"  Nice to meet you\" #> [4] \"     What are you up to? \\t \\t \""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_custom_summaries.html","id":null,"dir":"Reference","previous_headings":"","what":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","title":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","text":"function allows user define custom summaries performed call dplyr::summarize(). custom summary name default summary override default. allows user override default behavior summaries built 'Tplyr', also adding new desired summary functions.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_custom_summaries.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","text":"","code":"set_custom_summaries(e, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_custom_summaries.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","text":"e desc layer summaries bound ... Named parameters containing syntax used call dplyr::summarize()","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_custom_summaries.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","text":"Binds variable custom_summaries specified layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_custom_summaries.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","text":"programming logic summary function, use variable name .var within summary functions. allows apply summary function variable multiple target variables declared. important, yet immediately obvious, part using set_custom_summaries understand link named parameters set set_custom_summaries names called f_str objects within set_format_strings. f_str, supply string format like numbers take, specify summaries fill strings. go set format strings, name use declare summary set_custom_summaries name use f_str call. necessary set_format_strings needs means putting two summaries value, setting row label summary performed. Review examples see put practice. Note relationship name created set_custom_summaries name used set_format_strings within f_str call","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_custom_summaries.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","text":"","code":"#Load in pipe library(magrittr) tplyr_table(iris, Species) %>% add_layer( group_desc(Sepal.Length, by = \"Sepal Length\") %>% set_custom_summaries( geometric_mean = exp(sum(log(.var[.var > 0]), na.rm=TRUE) / length(.var)) ) %>% set_format_strings( 'Geometric Mean' = f_str('xx.xx', geometric_mean) ) ) %>% build() #> # A tibble: 1 × 8 #> row_label1 row_label2 var1_setosa var1_versicolor var1_virginica #> #> 1 Sepal Length Geometric Mean \" 4.99\" \" 5.91\" \" 6.56\" #> # ℹ 3 more variables: ord_layer_index , ord_layer_1 , #> # ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_ignore.html","id":null,"dir":"Reference","previous_headings":"","what":"Set values the denominator calculation will ignore — set_denom_ignore","title":"Set values the denominator calculation will ignore — set_denom_ignore","text":"`r lifecycle::badge(\"defunct\")` generally used missing values. Values like \"\", NA, \"NA\" common ways missing values presented data frame. certain cases, percentages use \"missing\" values denominator. function notes different values \"missing\" excludes denominators.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_ignore.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set values the denominator calculation will ignore — set_denom_ignore","text":"","code":"set_denom_ignore(e, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_ignore.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set values the denominator calculation will ignore — set_denom_ignore","text":"e count_layer object ... Values exclude percentage calculation. use `set_missing_counts()` name parameters instead values, see example .","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_ignore.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set values the denominator calculation will ignore — set_denom_ignore","text":"modified layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_ignore.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set values the denominator calculation will ignore — set_denom_ignore","text":"","code":"library(magrittr) mtcars2 <- mtcars mtcars2[mtcars$cyl == 6, \"cyl\"] <- NA mtcars2[mtcars$cyl == 8, \"cyl\"] <- \"Not Found\" tplyr_table(mtcars2, gear) %>% add_layer( group_count(cyl) %>% set_missing_count(f_str(\"xx \", n), Missing = c(NA, \"Not Found\")) # This function is currently deprecated. It was replaced with an # argument in set_missing_count # set_denom_ignore(\"Missing\") ) %>% build() #> # A tibble: 2 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 Missing \"14 \" \" 4 \" \" 3 \" 1 3"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_where.html","id":null,"dir":"Reference","previous_headings":"","what":"Set Logic for denominator subsetting — set_denom_where","title":"Set Logic for denominator subsetting — set_denom_where","text":"default, denominators count layers subset based layer level logic. cases might correct. functions allows user override behavior pass custom logic used subset target dataset calculating denominators layer.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_where.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set Logic for denominator subsetting — set_denom_where","text":"","code":"set_denom_where(e, denom_where)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_where.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set Logic for denominator subsetting — set_denom_where","text":"e count_layer/shift_layer object denom_where expression (.e. syntax) used subset target dataset calculating layer denominators. Supply programming logic (.e. x < 5 & y == 10). remove layer parameter subsetting total row thus percentage denominators, pass 'TRUE' function.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_where.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set Logic for denominator subsetting — set_denom_where","text":"modified Tplyr layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_where.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set Logic for denominator subsetting — set_denom_where","text":"","code":"library(magrittr) t10 <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl, where = cyl != 6) %>% set_denom_where(TRUE) # The denominators will be based on all of the values, including 6 ) %>% build()"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denoms_by.html","id":null,"dir":"Reference","previous_headings":"","what":"Set variables used in pct denominator calculation — set_denoms_by","title":"Set variables used in pct denominator calculation — set_denoms_by","text":"function used calculating pct count shift layers. percentages default treatment variable column variables can calculated variables passed target_var, treat_var, , cols.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denoms_by.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set variables used in pct denominator calculation — set_denoms_by","text":"","code":"set_denoms_by(e, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denoms_by.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set variables used in pct denominator calculation — set_denoms_by","text":"e count/shift layer object ... Unquoted variable names","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denoms_by.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set variables used in pct denominator calculation — set_denoms_by","text":"modified layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denoms_by.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set variables used in pct denominator calculation — set_denoms_by","text":"","code":"library(magrittr) # Default has matrix of treatment group, additional columns, # and by variables sum to 1 tplyr_table(mtcars, am) %>% add_layer( group_shift(vars(row=gear, column=carb), by=cyl) %>% set_format_strings(f_str(\"xxx (xx.xx%)\", n, pct)) ) %>% build() #> # A tibble: 9 × 17 #> row_label1 row_label2 var1_0_1 var1_0_2 var1_0_3 var1_0_4 var1_0_6 var1_0_8 #> #> 1 4 3 \" 1 (33.3… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 2 4 4 \" 0 ( 0.0… \" 2 (6… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 3 4 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 4 6 3 \" 2 (50.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 5 6 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 2 (5… \" 0 ( … \" 0 ( … #> 6 6 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 7 8 3 \" 0 ( 0.0… \" 4 (3… \" 3 (2… \" 5 (4… \" 0 ( … \" 0 ( … #> 8 8 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 9 8 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> # ℹ 9 more variables: var1_1_1 , var1_1_2 , var1_1_3 , #> # var1_1_4 , var1_1_6 , var1_1_8 , ord_layer_index , #> # ord_layer_1 , ord_layer_2 tplyr_table(mtcars, am) %>% add_layer( group_shift(vars(row=gear, column=carb), by=cyl) %>% set_format_strings(f_str(\"xxx (xx.xx%)\", n, pct)) %>% set_denoms_by(cyl, gear) # Row % sums to 1 ) %>% build() #> # A tibble: 9 × 17 #> row_label1 row_label2 var1_0_1 var1_0_2 var1_0_3 var1_0_4 var1_0_6 var1_0_8 #> #> 1 4 3 \" 1 (100.… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 2 4 4 \" 0 ( 0.0… \" 2 (2… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 3 4 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 4 6 3 \" 2 (100.… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 5 6 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 2 (5… \" 0 ( … \" 0 ( … #> 6 6 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 7 8 3 \" 0 ( 0.0… \" 4 (3… \" 3 (2… \" 5 (4… \" 0 ( … \" 0 ( … #> 8 8 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 9 8 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> # ℹ 9 more variables: var1_1_1 , var1_1_2 , var1_1_3 , #> # var1_1_4 , var1_1_6 , var1_1_8 , ord_layer_index , #> # ord_layer_1 , ord_layer_2 tplyr_table(mtcars, am) %>% add_layer( group_shift(vars(row=gear, column=carb), by=cyl) %>% set_format_strings(f_str(\"xxx (xx.xx%)\", n, pct)) %>% set_denoms_by(cyl, gear, am) # % within treatment group sums to 1 ) %>% build() #> # A tibble: 9 × 17 #> row_label1 row_label2 var1_0_1 var1_0_2 var1_0_3 var1_0_4 var1_0_6 var1_0_8 #> #> 1 4 3 \" 1 (100.… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 2 4 4 \" 0 ( 0.0… \" 2 (1… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 3 4 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 4 6 3 \" 2 (100.… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 5 6 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 2 (1… \" 0 ( … \" 0 ( … #> 6 6 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 7 8 3 \" 0 ( 0.0… \" 4 (3… \" 3 (2… \" 5 (4… \" 0 ( … \" 0 ( … #> 8 8 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 9 8 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> # ℹ 9 more variables: var1_1_1 , var1_1_2 , var1_1_3 , #> # var1_1_4 , var1_1_6 , var1_1_8 , ord_layer_index , #> # ord_layer_1 , ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/reference/set_distinct_by.html","id":null,"dir":"Reference","previous_headings":"","what":"Set counts to be distinct by some grouping variable. — set_distinct_by","title":"Set counts to be distinct by some grouping variable. — set_distinct_by","text":"situations, count summaries may want see distinct counts variable like subject. example, number subjects population particular adverse event. set_distinct_by allows set variables used determine distinct count.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_distinct_by.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set counts to be distinct by some grouping variable. — set_distinct_by","text":"","code":"set_distinct_by(e, distinct_by)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_distinct_by.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set counts to be distinct by some grouping variable. — set_distinct_by","text":"e count_layer/shift_layer object distinct_by Variable(s) get distinct data.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_distinct_by.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set counts to be distinct by some grouping variable. — set_distinct_by","text":"layer object ","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_distinct_by.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Set counts to be distinct by some grouping variable. — set_distinct_by","text":"distinct_by value set, distinct counts used default. wish combine distinct distinct counts, can choose display f_str() objects using n, pct, distinct_n, distinct_pct. Additionally, denominators may presented using total distinct_total","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_distinct_by.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set counts to be distinct by some grouping variable. — set_distinct_by","text":"","code":"#Load in pipe library(magrittr) tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% set_distinct_by(carb) ) %>% build() #> # A tibble: 3 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 25.0%)\" \" 2 ( 66.7%)\" \" 1 ( 25.0… 1 1 #> 2 6 \" 1 ( 25.0%)\" \" 1 ( 33.3%)\" \" 1 ( 25.0… 1 2 #> 3 8 \" 3 ( 75.0%)\" \" 0 ( 0.0%)\" \" 2 ( 50.0… 1 3"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_format_strings.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","title":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","text":"'Tplyr' gives extensive control strings presented. set_format_strings allows apply string formats layer. behaves slightly differently layers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_format_strings.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","text":"","code":"set_format_strings(e, ...) # S3 method for desc_layer set_format_strings(e, ..., cap = getOption(\"tplyr.precision_cap\")) # S3 method for count_layer set_format_strings(e, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_format_strings.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","text":"e Layer bind format strings ... Named parameters containing calls f_str set format strings cap named character vector containing 'int' element cap integer precision, 'dec' element cap decimal precision.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_format_strings.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","text":"layer environment format string binding added tplyr_layer object formats attached Returns modified layer object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_format_strings.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","text":"Format strings one powerful components 'Tplyr'. Traditionally, converting numeric values strings presentation can consume good deal time. Values decimals need align rows, rounding trimming sometimes forgotten - can become tedious mess , grand scheme things, important part analysis performed. 'Tplyr' makes process simple can, still allowing flexibility user. count layer, can simply provide single f_str object specify want n's, percentages, denominators formatted. additionally supplying statistic, like risk difference using add_risk_diff, specify count formats using name 'n_counts'. risk difference formats specified using name 'riskdiff'. descriptive statistic layer, set_format_strings allows couple things: naming parameters character strings, character strings become row label resulting data frame actual summaries performed come variable names used within f_str calls Using multiple summaries (declared f_str calls), multiple summary values can appear within line. example, present \"Mean (SD)\" like displays. Format strings desc layer also allow configure empty values presented. f_str call, use empty parameter specify missing values present. single element character vector provided. vector unnamed, value used format string fill space similar numbers display. Meaning - empty string 'NA' format string 'xx (xxx)', empty values populate 'NA ( NA)'. name character vector 'empty' parameter '.overall', like empty = c(.overall=''), exact string fill value instead. example, providing 'NA' instead create formatted string 'NA' exactly. See f_str documentation details implementation works.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_format_strings.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","text":"","code":"# Load in pipe library(magrittr) # In a count layer tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% set_format_strings(f_str('xx (xx%)', n, pct)) ) %>% build() #> # A tibble: 3 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 7%)\" \" 8 (67%)\" \" 2 (40%)\" 1 1 #> 2 6 \" 2 (13%)\" \" 4 (33%)\" \" 1 (20%)\" 1 2 #> 3 8 \"12 (80%)\" \" 0 ( 0%)\" \" 2 (40%)\" 1 3 # In a descriptive statistics layer tplyr_table(mtcars, gear) %>% add_layer( group_desc(mpg) %>% set_format_strings( \"n\" = f_str(\"xx\", n), \"Mean (SD)\" = f_str(\"xx.x\", mean, empty='NA'), \"SD\" = f_str(\"xx.xx\", sd), \"Median\" = f_str(\"xx.x\", median), \"Q1, Q3\" = f_str(\"xx, xx\", q1, q3, empty=c(.overall='NA')), \"Min, Max\" = f_str(\"xx, xx\", min, max), \"Missing\" = f_str(\"xx\", missing) ) ) %>% build() #> # A tibble: 7 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 n \"15\" \"12\" \" 5\" 1 1 #> 2 Mean (SD) \"16.1\" \"24.5\" \"21.4\" 1 2 #> 3 SD \" 3.37\" \" 5.28\" \" 6.66\" 1 3 #> 4 Median \"15.5\" \"22.8\" \"19.7\" 1 4 #> 5 Q1, Q3 \"14, 18\" \"21, 28\" \"16, 26\" 1 5 #> 6 Min, Max \"10, 22\" \"18, 34\" \"15, 30\" 1 6 #> 7 Missing \" 0\" \" 0\" \" 0\" 1 7 # In a shift layer tplyr_table(mtcars, am) %>% add_layer( group_shift(vars(row=gear, column=carb), by=cyl) %>% set_format_strings(f_str(\"xxx (xx.xx%)\", n, pct)) ) %>% build() #> # A tibble: 9 × 17 #> row_label1 row_label2 var1_0_1 var1_0_2 var1_0_3 var1_0_4 var1_0_6 var1_0_8 #> #> 1 4 3 \" 1 (33.3… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 2 4 4 \" 0 ( 0.0… \" 2 (6… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 3 4 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 4 6 3 \" 2 (50.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 5 6 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 2 (5… \" 0 ( … \" 0 ( … #> 6 6 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 7 8 3 \" 0 ( 0.0… \" 4 (3… \" 3 (2… \" 5 (4… \" 0 ( … \" 0 ( … #> 8 8 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 9 8 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> # ℹ 9 more variables: var1_1_1 , var1_1_2 , var1_1_3 , #> # var1_1_4 , var1_1_6 , var1_1_8 , ord_layer_index , #> # ord_layer_1 , ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/reference/set_indentation.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the option to prefix the row_labels in the inner count_layer — set_indentation","title":"Set the option to prefix the row_labels in the inner count_layer — set_indentation","text":"count layer uses nesting (.e. triggered set_nest_count), indentation argument's value used prefix inner layer's records","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_indentation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the option to prefix the row_labels in the inner count_layer — set_indentation","text":"","code":"set_indentation(e, indentation)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_indentation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the option to prefix the row_labels in the inner count_layer — set_indentation","text":"e count_layer object indentation character prefix row labels inner count layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_indentation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the option to prefix the row_labels in the inner count_layer — set_indentation","text":"modified count_layer environment","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_limit_data_by.html","id":null,"dir":"Reference","previous_headings":"","what":"Set variables to limit reported data values only to those that exist rather\nthan fully completing all possible levels — set_limit_data_by","title":"Set variables to limit reported data values only to those that exist rather\nthan fully completing all possible levels — set_limit_data_by","text":"function allows select combination variables potentially target variables want display values present data. default, Tplyr create cartesian combination potential values data. example, 2 variables present, potential combination variables row present final table. set_limit_data_by() allows choose variables whose combination wish limit values physically present available data.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_limit_data_by.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set variables to limit reported data values only to those that exist rather\nthan fully completing all possible levels — set_limit_data_by","text":"","code":"set_limit_data_by(e, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_limit_data_by.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set variables to limit reported data values only to those that exist rather\nthan fully completing all possible levels — set_limit_data_by","text":"e tplyr_layer ... Subset variables within target variables","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_limit_data_by.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set variables to limit reported data values only to those that exist rather\nthan fully completing all possible levels — set_limit_data_by","text":"tplyr_table","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_limit_data_by.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set variables to limit reported data values only to those that exist rather\nthan fully completing all possible levels — set_limit_data_by","text":"","code":"tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_desc(AVAL, by = vars(PECAT, PARAM, AVISIT)) ) %>% build() #> # A tibble: 72 × 11 #> row_label1 row_label2 row_label3 row_label4 `var1_TRT A` `var1_TRT B` #> #> 1 A Head Screening n \" 2\" \" 1\" #> 2 A Head Screening Mean (SD) \"5.0 (5.66)\" \"5.0 ( )\" #> 3 A Head Screening Median \"5.0\" \"5.0\" #> 4 A Head Screening Q1, Q3 \"3.0, 7.0\" \"5.0, 5.0\" #> 5 A Head Screening Min, Max \"1, 9\" \"5, 5\" #> 6 A Head Screening Missing \" 0\" \" 0\" #> 7 A Head Day -1 n \"\" \"\" #> 8 A Head Day -1 Mean (SD) \"\" \"\" #> 9 A Head Day -1 Median \"\" \"\" #> 10 A Head Day -1 Q1, Q3 \"\" \"\" #> # ℹ 62 more rows #> # ℹ 5 more variables: ord_layer_index , ord_layer_1 , #> # ord_layer_2 , ord_layer_3 , ord_layer_4 tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_desc(AVAL, by = vars(PECAT, PARAM, AVISIT)) %>% set_limit_data_by(PARAM, AVISIT) ) %>% build() #> # A tibble: 48 × 11 #> row_label1 row_label2 row_label3 row_label4 `var1_TRT A` `var1_TRT B` #> #> 1 A Head Screening n \" 2\" \" 1\" #> 2 A Head Screening Mean (SD) \"5.0 (5.66)\" \"5.0 ( )\" #> 3 A Head Screening Median \"5.0\" \"5.0\" #> 4 A Head Screening Q1, Q3 \"3.0, 7.0\" \"5.0, 5.0\" #> 5 A Head Screening Min, Max \"1, 9\" \"5, 5\" #> 6 A Head Screening Missing \" 0\" \" 0\" #> 7 B Head Screening n \"\" \"\" #> 8 B Head Screening Mean (SD) \"\" \"\" #> 9 B Head Screening Median \"\" \"\" #> 10 B Head Screening Q1, Q3 \"\" \"\" #> # ℹ 38 more rows #> # ℹ 5 more variables: ord_layer_index , ord_layer_1 , #> # ord_layer_2 , ord_layer_3 , ord_layer_4 tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_count(AVALC, by = vars(PECAT, PARAM, AVISIT)) %>% set_limit_data_by(PARAM, AVISIT) ) %>% build() #> # A tibble: 24 × 11 #> row_label1 row_label2 row_label3 row_label4 `var1_TRT A` `var1_TRT B` #> #> 1 A Head Screening Normal 2 ( 14.3%) 0 ( 0.0%) #> 2 A Head Screening Semi-Normal 0 ( 0.0%) 1 ( 14.3%) #> 3 A Head Screening Abnormal 0 ( 0.0%) 0 ( 0.0%) #> 4 B Head Screening Normal 0 ( 0.0%) 0 ( 0.0%) #> 5 B Head Screening Semi-Normal 0 ( 0.0%) 0 ( 0.0%) #> 6 B Head Screening Abnormal 0 ( 0.0%) 0 ( 0.0%) #> 7 A Lungs Screening Normal 1 ( 7.1%) 1 ( 14.3%) #> 8 A Lungs Screening Semi-Normal 0 ( 0.0%) 0 ( 0.0%) #> 9 A Lungs Screening Abnormal 1 ( 7.1%) 0 ( 0.0%) #> 10 B Lungs Screening Normal 1 ( 7.1%) 1 ( 14.3%) #> # ℹ 14 more rows #> # ℹ 5 more variables: ord_layer_index , ord_layer_1 , #> # ord_layer_2 , ord_layer_3 , ord_layer_4 tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_count(AVALC, by = vars(PECAT, PARAM, AVISIT)) %>% set_limit_data_by(PECAT, PARAM, AVISIT) ) %>% build() #> # A tibble: 21 × 11 #> row_label1 row_label2 row_label3 row_label4 `var1_TRT A` `var1_TRT B` #> #> 1 A Head Screening Normal 2 ( 14.3%) 0 ( 0.0%) #> 2 A Head Screening Semi-Normal 0 ( 0.0%) 1 ( 14.3%) #> 3 A Head Screening Abnormal 0 ( 0.0%) 0 ( 0.0%) #> 4 A Lungs Screening Normal 1 ( 7.1%) 1 ( 14.3%) #> 5 A Lungs Screening Semi-Normal 0 ( 0.0%) 0 ( 0.0%) #> 6 A Lungs Screening Abnormal 1 ( 7.1%) 0 ( 0.0%) #> 7 A Lungs Day -1 Normal 2 ( 14.3%) 1 ( 14.3%) #> 8 A Lungs Day -1 Semi-Normal 0 ( 0.0%) 0 ( 0.0%) #> 9 A Lungs Day -1 Abnormal 0 ( 0.0%) 0 ( 0.0%) #> 10 A Lungs Day 5 Normal 1 ( 7.1%) 1 ( 14.3%) #> # ℹ 11 more rows #> # ℹ 5 more variables: ord_layer_index , ord_layer_1 , #> # ord_layer_2 , ord_layer_3 , ord_layer_4 "},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_count.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the display for missing strings — set_missing_count","title":"Set the display for missing strings — set_missing_count","text":"Controls missing counts handled displayed layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_count.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the display for missing strings — set_missing_count","text":"","code":"set_missing_count(e, fmt = NULL, sort_value = NULL, denom_ignore = FALSE, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_count.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the display for missing strings — set_missing_count","text":"e count_layer object fmt f_str object change display missing counts sort_value numeric value used ordering column. numeric. supplied ordering column maximum value appears table plus one. denom_ignore boolean. Specifies Whether include missing counts specified within ... parameter within denominators. set TRUE, values specified within ... ignored. ... Parameters used note values describe missing. Generally NA \"Missing\" used . Parameters can named character vectors names become row label.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_count.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the display for missing strings — set_missing_count","text":"modified layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_count.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the display for missing strings — set_missing_count","text":"","code":"library(magrittr) library(dplyr) mtcars2 <- mtcars %>% mutate_all(as.character) mtcars2[mtcars$cyl == 6, \"cyl\"] <- NA tplyr_table(mtcars2, gear) %>% add_layer( group_count(cyl) %>% set_missing_count(f_str(\"xx \", n), Missing = NA) ) %>% build() #> # A tibble: 3 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 8 \"12 ( 80.0%)\" \" 0 ( 0.0%)\" \" 2 ( 40.0… 1 2 #> 3 Missing \" 2 \" \" 4 \" \" 1 \" 1 3"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_subjects_row_label.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the label for the missing subjects row — set_missing_subjects_row_label","title":"Set the label for the missing subjects row — set_missing_subjects_row_label","text":"Set label missing subjects row","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_subjects_row_label.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the label for the missing subjects row — set_missing_subjects_row_label","text":"","code":"set_missing_subjects_row_label(e, missing_subjects_row_label)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_subjects_row_label.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the label for the missing subjects row — set_missing_subjects_row_label","text":"e count_layer object missing_subjects_row_label character label total row","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_subjects_row_label.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the label for the missing subjects row — set_missing_subjects_row_label","text":"modified count_layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_subjects_row_label.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the label for the missing subjects row — set_missing_subjects_row_label","text":"","code":"t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% add_missing_subjects_row() %>% set_missing_subjects_row_label(\"Missing\") ) #> Warning: \tPopulation data was not set separately from the target data. #> \tMissing subject counts may be misleading in this scenario. #> \tDid you mean to use `set_missing_count() instead? build(t) #> # A tibble: 4 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 6 \" 2 ( 13.3%)\" \" 4 ( 33.3%)\" \" 1 ( 20.0… 1 2 #> 3 8 \"12 ( 80.0%)\" \" 0 ( 0.0%)\" \" 2 ( 40.0… 1 3 #> 4 Missing \" ( 0.0%)\" \" ( 0.0%)\" \" ( 0.0… 1 4"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_nest_count.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the option to nest count layers — set_nest_count","title":"Set the option to nest count layers — set_nest_count","text":"set TRUE, second variable specified target_var nested inside first variable. allows create displays like commonly used adverse event tables, one column holds labels outer categorical variable inside event variable (.e. AEBODSYS AEDECOD).","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_nest_count.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the option to nest count layers — set_nest_count","text":"","code":"set_nest_count(e, nest_count)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_nest_count.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the option to nest count layers — set_nest_count","text":"e count_layer object nest_count logical value set nest option","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_nest_count.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the option to nest count layers — set_nest_count","text":"modified layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_numeric_threshold.html","id":null,"dir":"Reference","previous_headings":"","what":"Set a numeric cutoff — set_numeric_threshold","title":"Set a numeric cutoff — set_numeric_threshold","text":"certain tables, may necessary include rows meet numeric conditions. Rows less certain cutoff can suppressed output. function allows pass cutoff, cutoff stat(n, distinct_n, pct, distinct_pct) supress values lesser cutoff.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_numeric_threshold.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set a numeric cutoff — set_numeric_threshold","text":"","code":"set_numeric_threshold(e, numeric_cutoff, stat, column = NULL)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_numeric_threshold.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set a numeric cutoff — set_numeric_threshold","text":"e count_layer object numeric_cutoff numeric value values greater equal displayed. stat statistic use filtering rows. Either 'n', 'distinct_n', 'pct' allowable column particular column used cutoff values, can supplied character value.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_numeric_threshold.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set a numeric cutoff — set_numeric_threshold","text":"modified Tplyr layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_numeric_threshold.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set a numeric cutoff — set_numeric_threshold","text":"","code":"mtcars %>% tplyr_table(gear) %>% add_layer( group_count(cyl) %>% set_numeric_threshold(10, \"n\") %>% add_total_row() %>% set_order_count_method(\"bycount\") ) #> *** tplyr_table *** #> Target (data.frame): #> \tName: . #> \tRows: 32 #> \tColumns: 11 #> treat_var variable (quosure) #> \tgear #> header_n: header groups #> treat_grps groupings (list) #> Table Columns (cols): #> where: TRUE #> Number of layer(s): 1 #> layer_output: 0"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_outer_sort_position.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the value of a outer nested count layer to Inf or -Inf — set_outer_sort_position","title":"Set the value of a outer nested count layer to Inf or -Inf — set_outer_sort_position","text":"Set value outer nested count layer Inf -Inf","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_outer_sort_position.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the value of a outer nested count layer to Inf or -Inf — set_outer_sort_position","text":"","code":"set_outer_sort_position(e, outer_sort_position)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_outer_sort_position.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the value of a outer nested count layer to Inf or -Inf — set_outer_sort_position","text":"e count_layer object outer_sort_position Either 'asc' 'desc'. desc final ordering helper set Inf, 'asc' ordering helper set -Inf.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_outer_sort_position.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the value of a outer nested count layer to Inf or -Inf — set_outer_sort_position","text":"modified count layer.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_precision_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Set precision data — set_precision_data","title":"Set precision data — set_precision_data","text":"cases, may organizational standards surrounding decimal precision. example, may specific standard around representation precision relating lab results. , set_precision_data() provides interface provide integer decimal precision external data source.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_precision_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set precision data — set_precision_data","text":"","code":"set_precision_data(layer, prec, default = c(\"error\", \"auto\"))"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_precision_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set precision data — set_precision_data","text":"layer tplyr_layer object prec dataframe following structure specified function details default Handling unspecified variable groupings. Defaults 'error'. Set 'auto' automatically infer missing groups.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_precision_data.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Set precision data — set_precision_data","text":"ultimate behavior feature just existing auto precision method, except precision specified provided precision dataset rather inferred source data. minimum, precision dataset must contain integer variables max_int max_dec. variables provided, variables must available layer variables. table built, default Tplyr error precision dataset missing variable groupings exist target dataset. can overriden using default parameter. default set \"auto\", missing values automatically inferred source data.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_precision_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set precision data — set_precision_data","text":"","code":"prec <- tibble::tribble( ~vs, ~max_int, ~max_dec, 0, 1, 1, 1, 2, 2 ) tplyr_table(mtcars, gear) %>% add_layer( group_desc(wt, by = vs) %>% set_format_strings( 'Mean (SD)' = f_str('a.a+1 (a.a+2)', mean, sd) ) %>% set_precision_data(prec) %>% set_precision_on(wt) ) %>% build() #> # A tibble: 2 × 8 #> row_label1 row_label2 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 0 Mean (SD) \"4.10 (0.768)\" \"2.75… \"2.91… 1 1 #> 2 1 Mean (SD) \" 3.047 ( 0.5… \" 2.5… \" 1.5… 1 2 #> # ℹ 1 more variable: ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/reference/set_stats_as_columns.html","id":null,"dir":"Reference","previous_headings":"","what":"Set descriptive statistics as columns — set_stats_as_columns","title":"Set descriptive statistics as columns — set_stats_as_columns","text":"many cases, treatment groups represented columns within table. tables call transposed presentation, treatment groups displayed row, descriptive statistics represented columns. set_stats_as_columns() allows Tplyr output built table using transposed format deviate away standard representation treatment groups columns.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_stats_as_columns.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set descriptive statistics as columns — set_stats_as_columns","text":"","code":"set_stats_as_columns(e, stats_as_columns = TRUE)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_stats_as_columns.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set descriptive statistics as columns — set_stats_as_columns","text":"e desc_layer descriptive statistics summaries represented columns stats_as_columns Boolean set stats columns","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_stats_as_columns.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set descriptive statistics as columns — set_stats_as_columns","text":"input tplyr_layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_stats_as_columns.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Set descriptive statistics as columns — set_stats_as_columns","text":"function leaves specified variables intact. switch happens build process provided descriptive statistics transposed columns treatment variable left rows. Column variables remain represented columns, multiple target variables also respected properly.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_stats_as_columns.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set descriptive statistics as columns — set_stats_as_columns","text":"","code":"dat <- tplyr_table(mtcars, gear) %>% add_layer( group_desc(wt, by = vs) %>% set_format_strings( \"n\" = f_str(\"xx\", n), \"sd\" = f_str(\"xx.x\", sd, empty = c(.overall = \"BLAH\")), \"Median\" = f_str(\"xx.x\", median), \"Q1, Q3\" = f_str(\"xx, xx\", q1, q3), \"Min, Max\" = f_str(\"xx, xx\", min, max), \"Missing\" = f_str(\"xx\", missing) ) %>% set_stats_as_columns() ) %>% build()"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_total_row_label.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the label for the total row — set_total_row_label","title":"Set the label for the total row — set_total_row_label","text":"row label total row defaults \"Total\", however can overriden using function.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_total_row_label.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the label for the total row — set_total_row_label","text":"","code":"set_total_row_label(e, total_row_label)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_total_row_label.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the label for the total row — set_total_row_label","text":"e count_layer object total_row_label character label total row","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_total_row_label.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the label for the total row — set_total_row_label","text":"modified count_layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_total_row_label.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the label for the total row — set_total_row_label","text":"","code":"# Load in pipe library(magrittr) t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% add_total_row() %>% set_total_row_label(\"Total Cyl\") ) build(t) #> # A tibble: 4 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 6 \" 2 ( 13.3%)\" \" 4 ( 33.3%)\" \" 1 ( 20.0… 1 2 #> 3 8 \"12 ( 80.0%)\" \" 0 ( 0.0%)\" \" 2 ( 40.0… 1 3 #> 4 Total Cyl \"15 (100.0%)\" \"12 (100.0%)\" \" 5 (100.0… 1 4"},{"path":"https://atorus-research.github.io/Tplyr/reference/str_extractors.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract format group strings or numbers — str_extract_fmt_group","title":"Extract format group strings or numbers — str_extract_fmt_group","text":"functions allow extract segments information within result string targetting specific format groups. str_extract_fmt_group() allows pull individual format group string, str_extract_num() allows pull specific numeric result.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_extractors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract format group strings or numbers — str_extract_fmt_group","text":"","code":"str_extract_fmt_group(string, format_group) str_extract_num(string, format_group)"},{"path":"https://atorus-research.github.io/Tplyr/reference/str_extractors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract format group strings or numbers — str_extract_fmt_group","text":"string string number results extract format groups format_group integer representing format group extracted","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_extractors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract format group strings or numbers — str_extract_fmt_group","text":"character vector","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_extractors.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract format group strings or numbers — str_extract_fmt_group","text":"Format groups refer individual segments string. example, given string ' 5 (34.4%) [9]', three separate format groups, ' 5', '(34.4%)', '[9]'.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_extractors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract format group strings or numbers — str_extract_fmt_group","text":"","code":"string <- c(\" 0 (0.0%)\", \" 8 (9.3%)\", \"78 (90.7%)\") str_extract_fmt_group(string, 2) #> [1] \"(0.0%)\" \"(9.3%)\" \"(90.7%)\" str_extract_num(string, 2) #> [1] 0.0 9.3 90.7"},{"path":"https://atorus-research.github.io/Tplyr/reference/str_indent_wrap.html","id":null,"dir":"Reference","previous_headings":"","what":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","title":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","text":"str_indent_wrap() leverages stringr::str_wrap() hood, takes extra steps preserve indentation applied character element, use hyphenated wrapping single words run longer allotted wrapping width.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_indent_wrap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","text":"","code":"str_indent_wrap(x, width = 10, tab_width = 5)"},{"path":"https://atorus-research.github.io/Tplyr/reference/str_indent_wrap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","text":"x input character vector width desired width elements within output character vector tab_width number spaces tabs converted","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_indent_wrap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","text":"character vector string wrapping applied","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_indent_wrap.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","text":"function stringr::str_wrap() highly efficient, context table creation two select features missing - hyphenation long running strings overflow width, respect pre-indentation character element. example, adverse event table, may body system rows un-indented column, preferred terms indented columns. strings may run long require wrapping surpass column width. Furthermore, crowded tables single word may longer column width . function takes steps resolve two issues, trying minimize additional overhead required apply wrapping strings. Note: function automatically converts tabs spaces. Tab width varies depending font, width automatically determined within data frame. , users can specify width","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_indent_wrap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","text":"","code":"ex_text1 <- c(\"RENAL AND URINARY DISORDERS\", \" NEPHROLITHIASIS\") ex_text2 <- c(\"RENAL AND URINARY DISORDERS\", \"\\tNEPHROLITHIASIS\") cat(paste(str_indent_wrap(ex_text1, width=8), collapse=\"\\n\\n\"),\"\\n\") #> RENAL #> AND #> URINARY #> DISORDE- #> RS #> #> NEPHROL- #> ITHIASI- #> S cat(paste(str_indent_wrap(ex_text2, tab_width=4), collapse=\"\\n\\n\"),\"\\n\") #> RENAL AND #> URINARY #> DISORDERS #> #> NEPHROLIT- #> HIASIS"},{"path":"https://atorus-research.github.io/Tplyr/reference/table_format_defaults.html","id":null,"dir":"Reference","previous_headings":"","what":"Get or set the default format strings for descriptive statistics layers — get_desc_layer_formats","title":"Get or set the default format strings for descriptive statistics layers — get_desc_layer_formats","text":"Tplyr provides ability set table-wide defaults format strings. may wish reuse format strings across numerous layers. set_desc_layer_formats set_count_layer_formats allow apply desired format strings within entire scope table.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/table_format_defaults.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get or set the default format strings for descriptive statistics layers — get_desc_layer_formats","text":"","code":"get_desc_layer_formats(obj) set_desc_layer_formats(obj, ...) get_count_layer_formats(obj) set_count_layer_formats(obj, ...) get_shift_layer_formats(obj) set_shift_layer_formats(obj, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/table_format_defaults.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get or set the default format strings for descriptive statistics layers — get_desc_layer_formats","text":"obj tplyr_table object ... formats pass forward","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/table_format_defaults.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Get or set the default format strings for descriptive statistics layers — get_desc_layer_formats","text":"descriptive statistic layers, can also use set_format_strings set_desc_layer_formats together within table, within layer. absence specified format strings, first table checked available defaults, otherwise tplyr.desc_layer_default_formats option used. set_format_strings always take precedence either. Defaults combined set_format_strings, set_desc_layer_formats, tplyr.desc_layer_default_formats order presentation results controlled format strings, relying combinations setting intuitive. count layers, can override n_counts riskdiff format strings separately, narrowest scope available used layer, table, default options.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/target_var.html","id":null,"dir":"Reference","previous_headings":"","what":"Set or return treat_var binding — get_target_var","title":"Set or return treat_var binding — get_target_var","text":"Set return treat_var binding","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/target_var.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set or return treat_var binding — get_target_var","text":"","code":"get_target_var(layer) set_target_var(layer, target_var)"},{"path":"https://atorus-research.github.io/Tplyr/reference/target_var.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set or return treat_var binding — get_target_var","text":"layer tplyr_layer object target_var symbol perform analysis ","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/target_var.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set or return treat_var binding — get_target_var","text":"treat_var, treatment variable binding layer object. set_treat_var, modified layer environment.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/target_var.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set or return treat_var binding — get_target_var","text":"","code":"# Load in pipe library(magrittr) iris$Species2 <- iris$Species lay <- tplyr_table(iris, Species) %>% group_count(Species) %>% set_target_var(Species2)"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adae.html","id":null,"dir":"Reference","previous_headings":"","what":"ADAE Data — tplyr_adae","title":"ADAE Data — tplyr_adae","text":"subset PHUSE Test Data Factory ADAE data set.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adae.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ADAE Data — tplyr_adae","text":"","code":"tplyr_adae"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adae.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"ADAE Data — tplyr_adae","text":"data.frame 276 rows 55 columns.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adae.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"ADAE Data — tplyr_adae","text":"https://github.com/phuse-org/TestDataFactory","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adas.html","id":null,"dir":"Reference","previous_headings":"","what":"ADAS Data — tplyr_adas","title":"ADAS Data — tplyr_adas","text":"subset PHUSE Test Data Factory ADAS data set.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adas.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ADAS Data — tplyr_adas","text":"","code":"tplyr_adas"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adas.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"ADAS Data — tplyr_adas","text":"data.frame 1,040 rows 40 columns.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adas.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"ADAS Data — tplyr_adas","text":"https://github.com/phuse-org/TestDataFactory","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adlb.html","id":null,"dir":"Reference","previous_headings":"","what":"ADLB Data — tplyr_adlb","title":"ADLB Data — tplyr_adlb","text":"subset PHUSE Test Data Factory ADLB data set.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adlb.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ADLB Data — tplyr_adlb","text":"","code":"tplyr_adlb"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adlb.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"ADLB Data — tplyr_adlb","text":"data.frame 311 rows 46 columns.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adlb.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"ADLB Data — tplyr_adlb","text":"https://github.com/phuse-org/TestDataFactory","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adpe.html","id":null,"dir":"Reference","previous_headings":"","what":"ADPE Data — tplyr_adpe","title":"ADPE Data — tplyr_adpe","text":"mock-dataset fit testing data limiting","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adpe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ADPE Data — tplyr_adpe","text":"","code":"tplyr_adpe"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adpe.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"ADPE Data — tplyr_adpe","text":"data.frame 21 rows 8 columns.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adsl.html","id":null,"dir":"Reference","previous_headings":"","what":"ADSL Data — tplyr_adsl","title":"ADSL Data — tplyr_adsl","text":"subset PHUSE Test Data Factory ADSL data set.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adsl.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ADSL Data — tplyr_adsl","text":"","code":"tplyr_adsl"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adsl.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"ADSL Data — tplyr_adsl","text":"data.frame 254 rows 49 columns.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adsl.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"ADSL Data — tplyr_adsl","text":"https://github.com/phuse-org/TestDataFactory","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a tplyr_layer object — tplyr_layer","title":"Create a tplyr_layer object — tplyr_layer","text":"object workhorse tplyr package. tplyr_layer can thought block, \"layer\" table. Summary tables typically consist different sections require different summaries. programming section, code create different layers need stacked merged together. tplyr_layer container isolated building blocks. building tplyr_table, layer execute independently. data processing completed, layers brought together construct output. tplyr_layer objects created directly, rather created using layer constructor functions group_count, group_desc, group_shift.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a tplyr_layer object — tplyr_layer","text":"","code":"tplyr_layer(parent, target_var, by, where, type, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a tplyr_layer object — tplyr_layer","text":"parent tplyr_table tplyr_layer. Required. parent environment layer. must either tplyr_table object layer contained within, another tplyr_layer object layer subgroup. target_var Symbol. Required, variable name summary performed. Must variable within target dataset. Enter unquoted - .e. target_var = AEBODSYS. string, variable name, list variable names supplied using dplyr::vars Call. Filter logic used subset target data performing summary. type \"count\", \"desc\", \"shift\". Required. category layer - either \"counts\" categorical counts, \"desc\" descriptive statistics, \"shift\" shift table counts ... Additional arguments","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a tplyr_layer object — tplyr_layer","text":"tplyr_layer environment child specified parent. environment contains object listed .","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_layer.html","id":"tplyr-layer-core-object-structure","dir":"Reference","previous_headings":"","what":"tplyr_layer Core Object Structure","title":"Create a tplyr_layer object — tplyr_layer","text":"type attribute. string indicating layer type, controls summary performed. target_var quosure name, variable summary performed. list quosures representing either text labels variable names used grouping. Variable names must exist within target dataset Text strings submitted need exist target dataset. cols list quosures used determine variables used display columns. quosure call containers filter logic used subset target dataset. filtering addition subsetting done based criteria specified tplyr_table layers list class tplyr_layer_container. Initialized empty, serves container sublayers current layer. Used internally. Different layer types different bindings specific layer's needs.","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a tplyr_layer object — tplyr_layer","text":"","code":"tab <- tplyr_table(iris, Sepal.Width) l <- group_count(tab, by=vars('Label Text', Species), target_var=Species, where= Sepal.Width < 5.5, cols = Species)"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_meta.html","id":null,"dir":"Reference","previous_headings":"","what":"Tplyr Metadata Object — tplyr_meta","title":"Tplyr Metadata Object — tplyr_meta","text":"Tplyr table built `metadata=TRUE` option specified, metadata assembled behind scenes provide traceability result cell derived. functions `get_meta_result()` `get_meta_subset()` allow access metadata using ID provided row_id column column name result like access. purpose row_id variable instead simple row index provide sort resistant reference originating column, output Tplyr table can sorted order metadata still easily accessible.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_meta.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tplyr Metadata Object — tplyr_meta","text":"","code":"tplyr_meta(names = list(), filters = exprs())"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_meta.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tplyr Metadata Object — tplyr_meta","text":"names List symbols filters List expressions","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_meta.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tplyr Metadata Object — tplyr_meta","text":"tplyr_meta object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_meta.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tplyr Metadata Object — tplyr_meta","text":"`tplyr_meta` object provided list two elements - names filters. names contain every column target data.frame Tplyr table factored specified result cell, filters contains necessary filters subset target data create specified result cell. `get_meta_subset()` additionally provides parameter specify additional columns like include returned subset data frame.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_meta.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tplyr Metadata Object — tplyr_meta","text":"","code":"tplyr_meta( names = rlang::quos(x, y, z), filters = rlang::quos(x == 1, y==2, z==3) ) #> tplyr_meta: 3 names, 3 filters #> Names: #> x, y, z #> Filters: #> x == 1, y == 2, z == 3"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_table.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a Tplyr table object — tplyr_table","title":"Create a Tplyr table object — tplyr_table","text":"tplyr_table object main container upon Tplyr table constructed. Tplyr tables made one layers. layer contains instruction summary performed. tplyr_table object contains layers, general data, metadata, logic necessary.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_table.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a Tplyr table object — tplyr_table","text":"","code":"tplyr_table(target, treat_var, where = TRUE, cols = vars())"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_table.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a Tplyr table object — tplyr_table","text":"target Dataset upon summaries performed treat_var Variable containing treatment group assignments. Supply unquoted. general subset applied layers. Supply programming logic (.e. x < 5 & y == 10) cols grouping variable summarize data column (addition treat_var). Provide multiple column variables using vars","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_table.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a Tplyr table object — tplyr_table","text":"tplyr_table object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_table.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create a Tplyr table object — tplyr_table","text":"tplyr_table created, contain following bindings: target - dataset upon summaries performed pop_data - data containing population information. defaults target dataset cols - categorical variable present summaries grouped column (addition treat_var) table_where - parameter provided, used subset target data treat_var - Variable used distinguish treatment groups. header_n - Default header N values based treat_var pop_treat_var - treatment variable pop_data (different) layers - container individual layers tplyr_table treat_grps - Additional treatment groups added summary (.e. Total) tplyr_table allows basic interface instantiate object. Modifier functions available change individual parameters catered analysis. example, add total group, can use add_total_group. future releases, provide vignettes fully demonstrate capabilities.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_table.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a Tplyr table object — tplyr_table","text":"","code":"tab <- tplyr_table(iris, Species, where = Sepal.Length < 5.8)"},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_grps.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine existing treatment groups for summary — add_treat_grps","title":"Combine existing treatment groups for summary — add_treat_grps","text":"Summary tables often present individual treatment groups, may additionally \"Treatment vs. Placebo\" \"Total\" group added show grouped summary statistics counts. set functions offers interface add groups table level consumed subsequent layers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_grps.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine existing treatment groups for summary — add_treat_grps","text":"","code":"add_treat_grps(table, ...) add_total_group(table, group_name = \"Total\") treat_grps(table)"},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_grps.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine existing treatment groups for summary — add_treat_grps","text":"table tplyr_table object ... named vector names become new treatment group names, values used construct treatment groups group_name treatment group name used constructed 'Total' group","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_grps.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine existing treatment groups for summary — add_treat_grps","text":"modified table object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_grps.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Combine existing treatment groups for summary — add_treat_grps","text":"add_treat_grps allows specify specific groupings. done supplying named arguments, name becomes new treatment group's name, treatment groups made argument's values. add_total_group simple wrapper around add_treat_grps. Instead producing custom groupings, produces \"Total\" group supplied name, defaults \"Total\". \"Total\" group made existing treatment groups within population dataset. Note using add_treat_grps add_total_row() set_pop_data(), call add_total_row() calling set_pop_data(), otherwise potential unexpected behaivior treatment groups. function treat_grps allows see custom treatment groups available tplyr_table object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_grps.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine existing treatment groups for summary — add_treat_grps","text":"","code":"tab <- tplyr_table(iris, Species) # A custom group add_treat_grps(tab, \"Not Setosa\" = c(\"versicolor\", \"virginica\")) #> *** tplyr_table *** #> Target (data.frame): #> \tName: iris #> \tRows: 150 #> \tColumns: 5 #> treat_var variable (quosure) #> \tSpecies #> header_n: header groups #> treat_grps groupings (list) #> \tNot Setosa #> Table Columns (cols): #> where: TRUE #> Number of layer(s): 0 #> layer_output: 0 # Add a total group add_total_group(tab) #> *** tplyr_table *** #> Target (data.frame): #> \tName: iris #> \tRows: 150 #> \tColumns: 5 #> treat_var variable (quosure) #> \tSpecies #> header_n: header groups #> treat_grps groupings (list) #> \tNot Setosa #> \tTotal #> Table Columns (cols): #> where: TRUE #> Number of layer(s): 0 #> layer_output: 0 treat_grps(tab) #> $`Not Setosa` #> [1] \"versicolor\" \"virginica\" #> #> $Total #> [1] \"setosa\" \"versicolor\" \"virginica\" #> # Returns: # $`Not Setosa` #[1] \"versicolor\" \"virginica\" # #$Total #[1] \"setosa\" \"versicolor\" \"virginica\""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_var.html","id":null,"dir":"Reference","previous_headings":"","what":"Return or set the treatment variable binding — treat_var","title":"Return or set the treatment variable binding — treat_var","text":"Return set treatment variable binding","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_var.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return or set the treatment variable binding — treat_var","text":"","code":"treat_var(table) set_treat_var(table, treat_var)"},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_var.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return or set the treatment variable binding — treat_var","text":"table tplyr_table object set return treatment variable table split . treat_var Variable containing treatment group assignments. Supply unquoted.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_var.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return or set the treatment variable binding — treat_var","text":"tplyr_treat_var treat_var binding tplyr_table object. set_tplyr_treat_var modified object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_var.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return or set the treatment variable binding — treat_var","text":"","code":"tab <- tplyr_table(mtcars, cyl) set_treat_var(tab, gear) #> *** tplyr_table *** #> Target (data.frame): #> \tName: mtcars #> \tRows: 32 #> \tColumns: 11 #> treat_var variable (quosure) #> \tgearpop_treat_var variable (quosure) #> \tcyl #> #> header_n: header groups #> treat_grps groupings (list) #> Table Columns (cols): #> where: TRUE #> Number of layer(s): 0 #> layer_output: 0"},{"path":"https://atorus-research.github.io/Tplyr/reference/where.html","id":null,"dir":"Reference","previous_headings":"","what":"Set or return where binding for layer or table — get_where.tplyr_layer","title":"Set or return where binding for layer or table — get_where.tplyr_layer","text":"Set return binding layer table","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/where.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set or return where binding for layer or table — get_where.tplyr_layer","text":"","code":"# S3 method for tplyr_layer get_where(obj) # S3 method for tplyr_layer set_where(obj, where) get_where(obj) # S3 method for tplyr_table get_where(obj) set_where(obj, where) # S3 method for tplyr_table set_where(obj, where) set_pop_where(obj, where) get_pop_where(obj)"},{"path":"https://atorus-research.github.io/Tplyr/reference/where.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set or return where binding for layer or table — get_where.tplyr_layer","text":"obj tplyr_layer tplyr_table object. expression (.e. syntax) used subset data. Supply programming logic (.e. x < 5 & y == 10)","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/where.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set or return where binding for layer or table — get_where.tplyr_layer","text":", binding supplied object. set_where, modified object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/where.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set or return where binding for layer or table — get_where.tplyr_layer","text":"","code":"# Load in pipe library(magrittr) iris$Species2 <- iris$Species lay <- tplyr_table(iris, Species) %>% group_count(Species) %>% set_where(Petal.Length > 3) %>% # Set logic for pop_data as well set_pop_where(Petal.Length > 3)"}] +[{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement Mike.Stackhouse@atorusresearch.com. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://atorus-research.github.io/Tplyr/CONTRIBUTING.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.0, available https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. Community Impact Guidelines inspired Mozilla’s code conduct enforcement ladder. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://atorus-research.github.io/Tplyr/ISSUE_TEMPLATE.html","id":"prerequisites","dir":"","previous_headings":"","what":"Prerequisites","title":"NA","text":"information, see CONTRIBUTING guide.","code":""},{"path":"https://atorus-research.github.io/Tplyr/ISSUE_TEMPLATE.html","id":"description","dir":"","previous_headings":"","what":"Description","title":"NA","text":"[Description bug feature]","code":""},{"path":"https://atorus-research.github.io/Tplyr/ISSUE_TEMPLATE.html","id":"steps-to-reproduce-bug-report-only","dir":"","previous_headings":"","what":"Steps to Reproduce (Bug Report Only)","title":"NA","text":"[First Step] [Second Step] […] Expected behavior: [expected happen] Actual behavior: [actually happened]","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/ISSUE_TEMPLATE.html","id":"versions","dir":"","previous_headings":"","what":"Versions","title":"NA","text":"can get information executing sessionInfo().","code":""},{"path":"https://atorus-research.github.io/Tplyr/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"The MIT License (MIT)","title":"The MIT License (MIT)","text":"Copyright © 2020 Atorus Research LLC Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://atorus-research.github.io/Tplyr/PULL_REQUEST_TEMPLATE.html","id":"types-of-changes","dir":"","previous_headings":"","what":"Types of changes","title":"NA","text":"Bug fix (non-breaking change fixes issue) New feature (non-breaking change adds functionality) Breaking change (fix feature cause existing functionality change) read CONTRIBUTING document. code follows code style project. change requires change documentation. updated documentation accordingly. added tests cover changes. new existing tests passed.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"how-tplyr-works","dir":"Articles","previous_headings":"","what":"How Tplyr Works","title":"Getting Started","text":"look summary table within clinical report, can often break basic pieces. Consider output. Different variables summarized chunks table, refer “layers”. Additionally, table really contains different types summaries, makes many calculations rather redundant. drives motivation behind Tplyr. containing table encapsulated within tplyr_table() object, section, “layer”, within summary table can broken tplyr_layer() object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"the-tplyr_table-object","dir":"Articles","previous_headings":"How Tplyr Works","what":"The tplyr_table() Object","title":"Getting Started","text":"tplyr_table() object conceptual “table” contains logic necessary construct display data. Tplyr tables made one layers. layer contains instruction summary performed. tplyr_table() object contains layers, general data, metadata, logic necessary prepare data layers constructed. tplyr_table() created, contain following bindings: target - dataset upon summaries performed count_layer_formats - Default formats used count layers table shift_layer_formats - Default formats used shift layers table desc_layer_formats - Default formats used descriptive statistics layers table pop_data - dataset containing population information. defaults target dataset cols - categorical variable target dataset present summaries grouped column (addition treat_var variable) table_where - clause provided, used subset target dataset treat_var - Variable used distinguish treatment groups target dataset. header_n - Default header N values based treat_var cols variables pop_treat_var - Variable used distinguish treatment groups pop_data dataset (different treat_var variable target dataset) layers - container individual layers tplyr_table() treat_grps - Additional treatment groups added summary (.e. Total) function tplyr_table() allows basic interface instantiate object. Modifier functions available change individual parameters catered analysis.","code":"t <- tplyr_table(tplyr_adsl, TRT01P, where = SAFFL == \"Y\") t #> *** tplyr_table *** #> Target (data.frame): #> Name: tplyr_adsl #> Rows: 254 #> Columns: 49 #> treat_var variable (quosure) #> TRT01P #> header_n: header groups #> treat_grps groupings (list) #> Table Columns (cols): #> where: == SAFFL Y #> Number of layer(s): 0 #> layer_output: 0"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"the-tplyr_layer-object","dir":"Articles","previous_headings":"How Tplyr Works","what":"The tplyr_layer() Object","title":"Getting Started","text":"Users Tplyr interface tplyr_layer() objects using group_ family functions. family specifies type summary performed within layer. count layers used create summary counts discrete variable. shift layers summarize counts different changes states. Lastly, desc layers create descriptive statistics. Count layers allow easily create summaries based counting distinct non-distinct occurrences values within variable. Additionally, layer allows create n (%) summaries ’re also summarizing proportion instances value occurs compared denominator. Count layers also capable producing counts nested relationships. example, want produce counts overall outside group, subgroup counts within group, can simply specify target variable vars(OutsideVariable, InsideVariable). allows tables like Adverse Events want see Preferred Terms within Body Systems, one layer. Count layers can also distinguish distinct non-distinct counts. Using specified variable, can count unique occurrences variable within specified grouping, including target. allows summary like unique subjects proportion experiencing adverse event, number total occurrences adverse event. Descriptive statistics layers perform summaries continuous variables. number summaries built Tplyr already can perform, including n, mean, median, standard deviation, variance, min, max, interquartile range, Q1, Q3, missing value counts. available summaries, default presentation descriptive statistics layer output ‘n’, ‘Mean (SD)’, ‘Median’, ‘Q1, Q3’, ‘Min, Max’, ‘Missing’. can change summaries using set_format_strings(), can also add summaries using set_custom_summaries(). allows easily implement additional summary statistics want presented. Shift layers largely abstraction count layer - fact, re-use lot code process layers. many shift tables, “” state presented rows table, “” state presented columns. clearly lays many subjects changed state baseline point time. Shift layers give intuitive API break , using similar interface layers. also number modifier functions available control nuanced aspects, denominators applied.","code":"cnt <- group_count(t, AGEGR1) cnt #> *** count_layer *** #> Self: count_layer < 0x55b20e8a83f0 > #> Parent: tplyr_table < 0x55b20dcbab30 > #> target_var: #> AGEGR1 #> by: #> where: TRUE #> Layer(s): 0 dsc <- group_desc(t, AGE) dsc #> *** desc_layer *** #> Self: desc_layer < 0x55b20f0c0d88 > #> Parent: tplyr_table < 0x55b20dcbab30 > #> target_var: #> AGE #> by: #> where: TRUE #> Layer(s): 0 shf <- group_shift(t, vars(row=COMP8FL, column=COMP24FL)) shf #> *** shift_layer *** #> Self: shift_layer < 0x55b20f267e18 > #> Parent: tplyr_table < 0x55b20dcbab30 > #> target_var: #> COMP8FL #> COMP24FL #> by: #> where: TRUE #> Layer(s): 0"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"adding-layers-to-a-table","dir":"Articles","previous_headings":"How Tplyr Works","what":"Adding Layers to a Table","title":"Getting Started","text":"Everyone style coding - ’ve tried flexible extent. Overall, Tplyr built around tidy syntax, object construction supports piping magrittr (.e. %>%). two ways add layers tplyr_table(): add_layer() add_layers(). difference add_layer() allows construct layer within call add_layer(), whereas add_layers() can attach multiple layers already constructed upfront: Within add_layer(), syntax constructing count layer Age Categories written fly. add_layer() special also allows use piping use modifier functions layer constructed add_layers(), hand, lets isolate code construct particular layer wanted separate things . might find cleaner work large number layers constructed. Notice construct layers separately, need specify table belong. add_layer() automatically. tplyr_table() tplyr_layer() objects built environments, parent/child relationships important. , even though layer knows table parent , layers still need attached table (table doesn’t know children ). Advanced R good job explaining environments R , benefits, use .","code":"t <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories n (%)\") ) t <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories n (%)\") %>% set_format_strings(f_str(\"xx (xx.x%)\", n, pct)) %>% add_total_row() ) t <- tplyr_table(tplyr_adsl, TRT01P) l1 <- group_count(t, AGEGR1, by = \"Age categories n (%)\") l2 <- group_desc(t, AGE, by = \"Age (years)\") t <- add_layers(t, l1, l2)"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"a-note-before-we-go-deeper","dir":"Articles","previous_headings":"How Tplyr Works > Adding Layers to a Table","what":"A Note Before We Go Deeper","title":"Getting Started","text":"Notice construct tplyr_table() tplyr_layer() displays summary information table layer? ’s create objects - constructs metadata, process actual data. allows construct make sure pieces table fit together data processing - gives container hold metadata, use later necessary. generate data tplyr_table() object, use function build(): ’s can get Tplyr. ’s great formatted numbers, numeric data behind scenes? Maybe number looks suspicious need investigate got number. want calculate statistics based counts? can get information well using get_numeric_data(). returns numeric data layer list data frames: storing pertinent information, can get Tplyr object processed data display. specifying want get data Tplyr, can save repeatedly processing data constructing outputs - particularly useful computation starts taking time.","code":"t <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories n (%)\") ) t %>% build() %>% kable() get_numeric_data(t) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"constructing-layers","dir":"Articles","previous_headings":"How Tplyr Works","what":"Constructing Layers","title":"Getting Started","text":"bulk Tplyr coding comes constructing layers specifying work want done. get , ’s important discuss Tplyr handles string formatting.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"string-formatting-in-tplyr","dir":"Articles","previous_headings":"How Tplyr Works > Constructing Layers","what":"String Formatting in Tplyr","title":"Getting Started","text":"String formatting Tplyr controlled object called f_str(), also name function use create formats. set format strings tplyr_layer(), use function set_format_strings(), usage varies slightly layer types (covered vignettes). - object necessary. Consider example: perfect world, f_str() calls wouldn’t necessary - reality allow us infer great deal information user inputs. calls see : row labels row_label2 column taken left side = set_format_strings() string formats, including integer length decimal precision, exact presentation formatting taken strings within first parameter f_str() call n = Number observations mean = Mean sd = Standard Deviation var = Variance iqr = Inter Quartile Range q1 = 1st quartile q3 = 3rd quartile min = Minimum value max = Maximum value missing = Count NA values two summaries placed f_str() call, two summaries formatted string. allows “Mean (SD)” type format numbers appear. simple user input controls significant amount work back end data processing, f_str() object allows metadata collected. f_str() objects also used count layers well control data presentation. Instead specifying summaries performed, use n, pct, distinct_n, distinct_pct parameters specify like values displayed. Using distinct_n distinct_pct combined specifying distinct_by() variable using set_distinct_by(). Really - format strings allow present data however like. ? Probably .","code":"t <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE, by = \"Age (years)\") %>% set_format_strings( 'n' = f_str('xx', n), 'Mean (SD)' = f_str('xx.xx (xx.xxx)', mean, sd) ) ) t %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories\") %>% set_format_strings(f_str('xx (xx.x)',n,pct)) ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories\") %>% set_format_strings(f_str('xx',n)) ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories\") %>% set_format_strings(f_str('xx (•◡•) xx.x%',n,pct)) ) %>% build() %>% kable()"},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"descriptive-statistic-layers","dir":"Articles","previous_headings":"Layer Types","what":"Descriptive Statistic Layers","title":"Getting Started","text":"covered string formatting, set_format_strings() controls great deal happens within descriptive statistics layer. Note built defaults ’s output: override defaults, just specify summaries want performed using set_format_strings() described . Tplyr doesn’t built function summary statistic want see? Well - can make ! set_custom_summaries() comes play. Let’s say want derive geometric mean. set_custom_summaries(), first name summary performed. important - name use f_str() call incorporate format. Next, program call function desired. happens background used call dplyr::summarize() - use similar syntax. Use variable name .var custom summary function. necessary allows generic variable name used multiple target variables specified - therefore function can applied target variables. Sometimes ’s need present multiple variables summarized side side. Tplyr allows well. Tplyr summarizes variables merges together. makes creating tables need compare BASE, AVAL, CHG next nice simple. Note use dplyr::vars() - situation ’d like use multiple variable names parameter, use dplyr::vars() specify variables. can use text strings calls dplyr::vars() well.","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE, by = \"Age (years)\") ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE, by = \"Sepal Length\") %>% set_custom_summaries( geometric_mean = exp(sum(log(.var[.var > 0]), na.rm=TRUE) / length(.var)) ) %>% set_format_strings( 'Geometric Mean (SD)' = f_str('xx.xx (xx.xxx)', geometric_mean, sd) ) ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(vars(AGE, AVGDD), by = \"Age and Avg. Daily Dose\") ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"count-layers","dir":"Articles","previous_headings":"Layer Types","what":"Count Layers","title":"Getting Started","text":"Count layers generally allow create “n” “n (%)” count type summaries. extra features well. Let’s say want total row within counts. can done add_total_row(): Sometimes ’s also necessary count summaries based distinct values. Tplyr allows well set_distinct_by(): ’s another trick going - create summary row label text like see , text strings can used target variables. , use combination set_distinct_by() count distinct subjects. Adverse event tables often call counting AEs something like body system counting actual events within body system. Tplyr means making simple user well. use dplyr::vars() specify multiple target variables. used count layer, Tplyr knows automatically first variable grouping variable second variable, counts shall produced merged together.","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(AGEGR1, by = \"Age categories\") %>% add_total_row() ) %>% build() %>% kable() tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count('Subjects with at least one adverse event') %>% set_distinct_by(USUBJID) %>% set_format_strings(f_str('xx', n)) ) %>% build() %>% kable() tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) ) %>% build() %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"shift-layers","dir":"Articles","previous_headings":"Layer Types","what":"Shift Layers","title":"Getting Started","text":"Lastly, let’s talk shift layers. common example looking subject’s lab levels baseline versus designated evaluation point. tell us, example, many subjects high baseline lab test vs. intervention introduced. shift layer Tplyr intended creating shift tables show data matrix, one state presented rows columns. Let’s look example. underlying process shift tables count layers - ’re counting number occurrences something set grouping variables. differs Tplyr uses group_shift() API use basic interface tables, translate target variables row variable column variable. Furthermore, enhanced control denominators behave necessary shift layer.","code":"# Tplyr can use factor orders to dummy values and order presentation tplyr_adlb$ANRIND <- factor(tplyr_adlb$ANRIND, c(\"L\", \"N\", \"H\")) tplyr_adlb$BNRIND <- factor(tplyr_adlb$BNRIND, c(\"L\", \"N\", \"H\")) tplyr_table(tplyr_adlb, TRTA, where = PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row=BNRIND, column=ANRIND), by=PARAM) %>% set_format_strings(f_str(\"xx (xxx%)\", n, pct)) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"where-to-go-from-here","dir":"Articles","previous_headings":"","what":"Where to go from here?","title":"Getting Started","text":"’s quite bit learn! ’ve prepared number vignettes help get need Tplyr. Learn table level settings vignette(\"table\") Learn descriptive statistics layers vignette(\"desc\") Learn count shift layers vignette(\"count\") Learn shift layers vignette(\"shift\") Learn calculating risk differences vignette(\"riskdiff\") Learn sorting Tplyr tables vignette(\"sort\") Learn using Tplyr options vignette(\"options\") finally, learn producing outputting styled tables using Tplyr vignette(\"styled-table\")","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/Tplyr.html","id":"references","dir":"Articles","previous_headings":"","what":"References","title":"Getting Started","text":"building Tplyr, needed additional resources addition personal experience help guide design. PHUSE done great work create guidance standard outputs collaboration multiple pharmaceutical companies FDA. can find resource referenced . Analysis Displays Associated Adverse Events Analyses Displays Associated Demographics, Disposition, Medications Analyses Displays Associated Measures Central Tendency","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/count.html","id":"a-simple-example","dir":"Articles","previous_headings":"","what":"A Simple Example","title":"Count Layers","text":"Let’s start basic example. table demonstrates distribution subject disposition across treatment groups. Additionally, ’re sorting descending total occurrences using “Total” group.","code":"t <- tplyr_table(tplyr_adsl, TRT01P, where = SAFFL == \"Y\") %>% add_total_group() %>% add_treat_grps(Treated = c(\"Xanomeline Low Dose\", \"Xanomeline High Dose\")) %>% add_layer( group_count(DCDECOD) %>% set_order_count_method(\"bycount\") %>% set_ordering_cols(Total) ) %>% build() %>% arrange(desc(ord_layer_1)) %>% select(starts_with(\"row\"), var1_Placebo, `var1_Xanomeline Low Dose`, `var1_Xanomeline High Dose`, var1_Treated, var1_Total) kable(t)"},{"path":"https://atorus-research.github.io/Tplyr/articles/count.html","id":"distinct-versus-event-counts","dir":"Articles","previous_headings":"","what":"Distinct Versus Event Counts","title":"Count Layers","text":"Another exceptionally important consideration within count layers whether using distinct counts, non-distinct counts, combination . Adverse event tables perfect example. Often, ’re concerned many subjects adverse event particular instead just number occurrences adverse event. Similarly, number occurrences event isn’t necessarily relevant compared total number adverse events occurred. reason, likely want look instead number subjects experienced event compared total number subjects treatment group. Tplyr allows focus distinct counts distinct percents within grouping variable, like subject. Additionally, can mix match distinct counts non-distinct counts row . set_distinct_by() function sets variables used calculate distinct occurrences value using specified distinct_by variables. may seen tables like one . display shows number subjects experienced adverse event, percentage subjects within given treatment group experienced event, total number occurrences event. Using set_distinct_by() triggered derivation distinct_n distinct_pct addition n pct created within group_count. display values controlled f_str() call set_format_strings(). additional option formatting numbers using ‘parenthesis hugging’. trigger , integer side number use capital ‘X’ capital ‘’. example: can seen , using parenthesis hugging, width specified format group preserved, preceding character (characters) left ‘X’ ‘’ pulled right ‘hug’ specified number.","code":"t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% set_format_strings(f_str(\"xxx (xx.xx%) [xxx]\", distinct_n, distinct_pct, n)) ) %>% build() %>% head() kable(t) t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% set_format_strings(f_str(\"xxx (XXX.xx%) [A]\", distinct_n, distinct_pct, n)) ) %>% build() %>% head() %>% select(row_label1, `var1_Xanomeline Low Dose`) t #> # A tibble: 6 × 2 #> row_label1 `var1_Xanomeline Low Dose` #> #> 1 ACTINIC KERATOSIS \" 0 (0.00%) [0]\" #> 2 ALOPECIA \" 0 (0.00%) [0]\" #> 3 BLISTER \" 5 (11.90%) [8]\" #> 4 COLD SWEAT \" 0 (0.00%) [0]\" #> 5 DERMATITIS ATOPIC \" 0 (0.00%) [0]\" #> 6 DERMATITIS CONTACT \" 1 (2.38%) [2]\""},{"path":"https://atorus-research.github.io/Tplyr/articles/count.html","id":"nested-count-summaries","dir":"Articles","previous_headings":"","what":"Nested Count Summaries","title":"Count Layers","text":"Certain summary tables present counts within groups. One example disposition table disposition reason “” summarizes reasons . common example Adverse Event table displays counts body systems, events within body systems. nuanced situation - two variables summarized: body system counts, advert event counts. One way approach creating two summaries. One summarizing body system, another summarizing preferred terms body system, merging two together. don’t want . Instead, handle complexity . done group_count() submitting two target variables dplyr::vars(). first variable grouping variable want summarized, refer “Outside” variable, second narrower scope, call “Inside” variable. example demonstrates nested summary. Look first row - row_label1 row_label2 “CARDIAC DISORDERS”. line summary AEBODSYS. rows , row_label1 continues value “CARDIAC DISORDERS”, row_label2 changes. summaries AEDECOD. accomplishes needed, ’s exactly presentation might hope . solution well. using set_nest_count(), triggers Tplyr drop row_label1, indent AEDECOD values within row_label2. columns renamed appropriately well. default indentation used 3 spaces, can see - can set indentation however like. let’s use tab strings different language-specific output types, stick spaces, indent wider smaller - whatever wish. existing order variables remain, impact ability sort table. ’s lot counting! sure check vignettes sorting, shift tables, denominators.","code":"tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) ) %>% build() %>% head() %>% kable() tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) %>% set_nest_count(TRUE) %>% set_indentation(\"--->\") ) %>% build() %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/custom-metadata.html","id":"build-a-tplyr_meta-object","dir":"Articles","previous_headings":"","what":"Build a tplyr_meta object","title":"Creating Custom Tplyr Metadata","text":"covered vignette('metadata'), tplyr_meta object consists two different fields: list variable names, list filter conditions. provide fields list quosures: tplyr_meta() function can take fields immediately upon creation. need dynamically create tplyr_meta object Tplyr constructs objects internally), functions add_variables() add_filters() available extend existing tplyr_meta object:","code":"m <- tplyr_meta( names = quos(a, b, c), filters = quos(a==1, b==2, c==3) ) m #> tplyr_meta: 3 names, 3 filters #> Names: #> a, b, c #> Filters: #> a == 1, b == 2, c == 3 m <- m %>% add_variables(quos(x)) %>% add_filters(quos(x == 'a')) m #> tplyr_meta: 4 names, 4 filters #> Names: #> a, b, c, x #> Filters: #> a == 1, b == 2, c == 3, x == \"a\""},{"path":"https://atorus-research.github.io/Tplyr/articles/custom-metadata.html","id":"building-your-own-metadata-table","dir":"Articles","previous_headings":"","what":"Building your own metadata table","title":"Creating Custom Tplyr Metadata","text":"Now can create tplyr_meta objects, let’s assemble metadata bottom portion Table 14-3.01: Let’s break happened : First, assemble overarching metadata object model. lot metadata shared across different result cells efficacy data, can start collecting information tplyr_meta object. Next, can use starting point build tplyr_meta objects result cells. model data contains contrasts different treatment group comparisons. using add_filters(), can create additional three tplyr_meta objects using starting point attaching additional filter condition. Lastly, extend metadata original tplyr_table object created summary portion table, need data frame. ’s lot ways , like display explicitness tibble::tribble(). building data frame use tplyr_table metadata, really two rules: need column data frame called row_id row_id values duplicates value within existing metadata. row_id values built Tplyr always follow format “n_n”, first letter layer type either “c”, “d”, “s”. next number layer number (.e. order layer inserted Tplyr table), finally row layer within output. example, third row count layer second layer table row_id “c2_3”. example, chose “x4_n” format “x” symbolize custom, data can thought fourth layer. said, values typically masked viewer table really just need unique - can choose whatever want.","code":"# Overall model subset of data meta <- tplyr_meta( names = quos(TRTP, EFFFL, ITTFL, ANL01FL, SITEGR1, AVISIT, AVISITN, PARAMCD, AVAL, BASE, CHG), filters = quos(EFFFL == \"Y\", ITTFL == \"Y\", PARAMCD == \"ACTOT\", ANL01FL == \"Y\", AVISITN == 24) ) # Xan High / Placebo contrast meta_xhp <- meta %>% add_filters(quos(TRTP %in% c(\"Xanomeline High Dose\", \"Placebo\"))) # Xan Low / Placbo Contrast meta_xlp <- meta %>% add_filters(quos(TRTP %in% c(\"Xanomeline Low Dose\", \"Placebo\"))) # Xan High / Xan Low Contrast meta_xlh <- meta %>% add_filters(quos(TRTP %in% c(\"Xanomeline High Dose\", \"Xanomeline Low Dose\"))) eff_meta <- tibble::tribble( ~\"row_id\", ~\"row_label1\", ~\"var1_Xanomeline Low Dose\", ~\"var1_Xanomeline High Dose\", \"x4_1\", \"p-value(Dose Response) [1][2]\", NULL, meta, \"x4_3\", \"p-value(Xan - Placebo) [1][3]\", meta_xlp, meta_xhp, \"x4_4\", \" Diff of LS Means (SE)\", meta_xlp, meta_xhp, \"x4_5\", \" 95% CI\", meta_xlp, meta_xhp, \"x4_7\", \"p-value(Xan High - Xan Low) [1][3]\", NULL, meta_xlh, \"x4_8\", \" Diff of LS Means (SE)\", NULL, meta_xlh, \"x4_9\", \" 95% CI\", NULL, meta_xlh )"},{"path":"https://atorus-research.github.io/Tplyr/articles/custom-metadata.html","id":"anti-joins","dir":"Articles","previous_headings":"Building your own metadata table","what":"Anti-joins","title":"Creating Custom Tplyr Metadata","text":"custom metadata ’re constructing requires references data outside target dataset, also possible tplyr_meta object. ’re looking non-overlap target dataset, can use anti-join. Anti-joins can added tplyr_meta object using add_anti_join() function.","code":"meta %>% add_anti_join( join_meta = tplyr_meta( names = quos(TRT01P, EFFFL, ITTFL, SITEGR1), filters = quos(EFFFL == \"Y\", ITTFL == \"Y\") ), on = quos(USUBJID) ) #> tplyr_meta: 11 names, 5 filters #> Names: #> TRTP, EFFFL, ITTFL, ANL01FL, SITEGR1, AVISIT, AVISITN, PARAMCD, AVAL, BASE, CHG #> Filters: #> EFFFL == \"Y\", ITTFL == \"Y\", PARAMCD == \"ACTOT\", ANL01FL == \"Y\", AVISITN == 24 #> Anti-join: #> Join Meta: #> tplyr_meta: 4 names, 2 filters #> Names: #> TRT01P, EFFFL, ITTFL, SITEGR1 #> Filters: #> EFFFL == \"Y\", ITTFL == \"Y\" #> On: #> USUBJID"},{"path":"https://atorus-research.github.io/Tplyr/articles/custom-metadata.html","id":"appending-existing-tplyr-metadata","dir":"Articles","previous_headings":"","what":"Appending Existing Tplyr Metadata","title":"Creating Custom Tplyr Metadata","text":"Now ’ve created custom extension Tplyr metadata, let’s extend existing data frame. , Tplyr function append_metadata(): Behind scenes, function simply binds new metadata old proper section tplyr_table object. can view tplyr_table metadata function get_metadata(): Finally, automatically created metadata Tplyr, can query result cells just :","code":"t <- append_metadata(t, eff_meta) get_metadata(t) #> # A tibble: 16 × 6 #> row_id row_label1 row_label2 var1_Placebo var1_Xanomeline High…¹ #> #> 1 d1_1 \"Baseline\" n #> 2 d2_1 \"Baseline\" Mean (SD) #> 3 d3_1 \"Baseline\" Median (R… #> 4 d1_2 \"Week 24\" n #> 5 d2_2 \"Week 24\" Mean (SD) #> 6 d3_2 \"Week 24\" Median (R… #> 7 d1_3 \"Change from Baseline\" n #> 8 d2_3 \"Change from Baseline\" Mean (SD) #> 9 d3_3 \"Change from Baseline\" Median (R… #> 10 x4_1 \"p-value(Dose Response… NA #> 11 x4_3 \"p-value(Xan - Placebo… NA #> 12 x4_4 \" Diff of LS Means (… NA #> 13 x4_5 \" 95% CI\" NA #> 14 x4_7 \"p-value(Xan High - Xa… NA #> 15 x4_8 \" Diff of LS Means (… NA #> 16 x4_9 \" 95% CI\" NA #> # ℹ abbreviated name: ¹​`var1_Xanomeline High Dose` #> # ℹ 1 more variable: `var1_Xanomeline Low Dose` get_meta_subset(t, 'x4_1', \"var1_Xanomeline High Dose\") %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/custom-metadata.html","id":"metadata-without-tplyr","dir":"Articles","previous_headings":"","what":"Metadata Without Tplyr","title":"Creating Custom Tplyr Metadata","text":"well may scenario want use metadata functions outside Tplyr general. , S3 methods available query metadata dataframe instead Tplyr table, parameters provide target data frame: Tplyr metadata, strict criteria custom metadata row_id column.","code":"get_meta_subset(eff_meta, 'x4_1', \"var1_Xanomeline High Dose\", target=tplyr_adas) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/custom-metadata.html","id":"tying-it-together","dir":"Articles","previous_headings":"","what":"Tying it Together","title":"Creating Custom Tplyr Metadata","text":"vignette wouldn’t complete without final contextual example - go. Ultimately pieces fit together context Shiny application give desired click-experience. Source code available ","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"population-data-in-the-denominator","dir":"Articles","previous_headings":"","what":"Population Data in the Denominator","title":"Totals, Missings, and Denominators","text":"target dataset doesn’t information necessary create denominator? example - create adverse event table, adverse event dataset likely contains records subjects experienced adverse event. subjects adverse event still part study population must considered denominator. reason,Tplyr allows lets set separate population dataset - couple things need trigger Tplyr use population data denominator. Consider two examples. three things done use population data: Population data must set first place using set_pop_where() population treatment variable must specified using set_pop_treat_var() set_distinct_by() must used. ? need use separate population dataset, target dataset likely one record per subject. set_distinct_by() scenario used get distinct counts per subject. example, ’re looking number unique subjects experienced specific adverse event. population denominator used calculating distinct_pct. also worth noting default count layer formats use distinct values. Note need control values used denominator population data, can set separate filter population data used set_pop_where(). Fortunately, denominators much simpler ’re kept within single dataset. Just kidding! Let’s get weird.","code":"tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% set_format_strings(f_str('xx (xx.x%)', distinct_n, distinct_pct)) ) %>% build() %>% head() %>% kable() tplyr_table(tplyr_adae, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% set_format_strings(f_str('xx (xx.x%)', distinct_n, distinct_pct)) ) %>% build() %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"denominator-grouping","dir":"Articles","previous_headings":"","what":"Denominator Grouping","title":"Totals, Missings, and Denominators","text":"’re looking within single dataset, couple factors need consider denominator. first grouping variables create denominators. Let’s look two perspectives - count layers shift layers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"count-layers","dir":"Articles","previous_headings":"Denominator Grouping","what":"Count layers","title":"Totals, Missings, and Denominators","text":"complexity denominators comes nuanced situations. solid 80% time, defaults work. example, frequency table, typically want data within column sum 100%. example: default, using population data strategy shown , count layer assumes want columns sum 100%. ’s always case. Perhaps ’d like break summary sex presented row-wise. Ok - , now little bit . breaking sex row group, denominators still total treatment group. make sense? 34 female Placebo group subjects completed, calculated 39.5% also includes male subjects denominator. Let’s fix using set_denoms_by(). Ok - much better. set_denoms_by() now changed denominator grouping us, denominator used 34 female Placebo subjects now total number female Placebo subjects. Makes sense, right? set_denoms_by() allows specify: treatment variable cols variables specified table level variables specified layer level Depending presentation, require may change - flexibility choose need.","code":"tplyr_adsl <- tplyr_adsl %>% mutate(DCSREAS = ifelse(DCSREAS == '', 'Completed', DCSREAS)) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(DCSREAS) ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(DCSREAS, by=SEX) ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(DCSREAS, by=SEX) %>% set_denoms_by(SEX, TRT01P) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"shift-layers","dir":"Articles","previous_headings":"Denominator Grouping","what":"Shift layers","title":"Totals, Missings, and Denominators","text":"major part shift API control denominators used calculation percentages. shift tables, percentages relative “box” formed “” “” groups shift treatment group. Just like count layers, set_denoms_by() functions variable name treatment variable, cols argument, variables. difference shift layers now can also include target variables used row column. example , denominators based treatment variables, TRTA, PARAM VISIT. creates 3 X 3 box, denominator total record within shift variables, within parameter, visit, treatment. default, Tplyr create denominators set_denoms_by() isn’t specified. next example, percentage denominators calculated row-wise, row percentage sums 100%. practical, last example denominators changed based entire column instead 3 x 3 box. passing column variables, TRTA ANRIND layer use denominators determining percentages. hope gives flexibility need structure denominator however required.","code":"tplyr_table(tplyr_adlb, TRTA, where=PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, AVISIT)) %>% set_format_strings(f_str(\"xx (xxx.x%)\", n, pct)) %>% # This is the default, the 3x3 box formed by the target variables set_denoms_by(TRTA, PARAM, AVISIT) ) %>% build() %>% kable() tplyr_table(tplyr_adlb, TRTA, where=PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, AVISIT)) %>% set_format_strings(f_str(\"xx (xxx.x%)\", n, pct)) %>% set_denoms_by(TRTA, PARAM, AVISIT, BNRIND) # Each row made by TRTA, BNRIND ) %>% build() %>% arrange(ord_layer_1, ord_layer_2, ord_layer_3) %>% head() %>% kable() tplyr_table(tplyr_adlb, TRTA, where = PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, AVISIT)) %>% set_format_strings(f_str(\"xx (xx.xx%)\", n, pct)) %>% set_denoms_by(TRTA, ANRIND) # Use the column total as the denominator ) %>% build() %>% arrange(ord_layer_1, ord_layer_2, ord_layer_3) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"controlling-the-denominator-filter","dir":"Articles","previous_headings":"","what":"Controlling the Denominator Filter","title":"Totals, Missings, and Denominators","text":"circumstances ’ll encounter filter used denominator needs different filter used count. Disposition tables example , ’ll use example paint picture. Tplyroffers ability specifically control filter used within denominator. provided function set_denom_where(). default set_denom_where() layer level parameter, one supplied. set_denom_where() allows replace layer level filter custom filter choosing. done top filtering specified tplyr_table() parameter - means set_denom_where() filter applied addition table level filtering. Yeah know - lot different places filtering can happen… let’s take example shown . first layer layer level filtering applied, table level filter applied. second layer layer level filter applied, denominators based layer level filter. Notice case, percentages second layer add 100%. denominator includes values used layer. third layer layer level filter applied, additionally uses set_denom_where(). set_denom_where() example actually removing layer level filter denominators. R, filter using TRUE, filter returns records. using TRUE set_denom_where(), layer level filter effectively removed. causes denominator include values available table just selected layer - layer, percentages add 100%. important - allows percentages Layer 3 sum total percentage “DISCONTINUED” Layer 1.","code":"tplyr_adsl2 <- tplyr_adsl %>% mutate(DISCONTEXT = if_else(DISCONFL == 'Y', 'DISCONTINUED', 'COMPLETED')) t <- tplyr_table(tplyr_adsl2, TRT01P, where = SAFFL == 'Y') %>% add_layer( group_count(DISCONTEXT) ) %>% add_layer( group_count(DCSREAS, where = DISCONFL == 'Y') ) %>% add_layer( group_count(DCSREAS, where = DISCONFL == 'Y') %>% set_denom_where(TRUE) ) %>% build() %>% arrange(ord_layer_index, ord_layer_1) t %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"missing-counts","dir":"Articles","previous_headings":"","what":"Missing Counts","title":"Totals, Missings, and Denominators","text":"Missing counts tricky area frequency tables, play directly denominators well. values raise number questions. example, want format missing counts way event counts? want present missing counts percentages? missing counts belong denominator? set_missing_count() function can take new f_str() object set display missing values. specified, associated count layer’s format used. Using ... parameter, able specify row label desired missing values values determine considered ‘missing’. example, may NA values target variable, values like “Collected” also wish consider “missing”. set_missing_count() allows group together. Actually - ’re able establish many different “missing” groups want - even though scenario fairly unlikely. example 50 random values removed NA specified missing string. leads us another parameter - denom_ignore. default, specify missing values still considered within denominator, missing counts, may wish exclude totals summarized. setting denom_ignore TRUE, denominators ignore groups missing values ’ve specified. one thing worth explaining example - gave missing count sort value. leave field null, simply maximum value order layer plus 1, put Missing counts bottom ascending sort. tables can sorted lot different ways, ’ll see sort vignette. instead trying come novel ways control missing row goes - decided just let specify value.","code":"tplyr_adae2 <- tplyr_adae tplyr_adae2[sample(nrow(tplyr_adae2), 50), \"AESEV\"] <- NA t <- tplyr_table(tplyr_adae2, TRTA) %>% add_layer( group_count(AESEV) %>% set_format_strings(f_str(\"xxx (xx.xx%)\", n, pct)) %>% set_missing_count(f_str(\"xxx\", n), sort_value=Inf, denom_ignore=TRUE, Missing = NA) ) %>% build() %>% arrange(ord_layer_1) t %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"missing-subjects","dir":"Articles","previous_headings":"","what":"Missing Subjects","title":"Totals, Missings, and Denominators","text":"Missing counts counting missing subjects work two different ways within Tplyr. Missing counts, described , examine records present data collect missing values. results counted, need first provided within input data . hand, missing subjects calculated looking difference potential number subjects within column (.e. combination treatment variables column variables) number subjects actually present. Consider example: example , produce nested count layer. function add_missing_subjects_row() triggers addition new result row missing subjects calculated. row label applied can configured using set_missing_subjects_row_label(), row label default ‘Missing’. Depending sorting needs, sort_value can applied whatever numeric value provide. Lastly, can provide f_str() format missing subjects row separately rest layer, whatever format applied layer apply otherwise. Note nested count layers, missing subject rows generate independent group within outer layer. Outer layers missing subject rows calculated individually. best done independent layer , result apply whole input target dataset.","code":"missing_subs <- tplyr_table(tplyr_adae, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) %>% set_nest_count(TRUE) %>% set_distinct_by(USUBJID) %>% add_missing_subjects_row(f_str(\"xx (XX.x%)\", distinct_n, distinct_pct), sort_value = Inf) %>% set_missing_subjects_row_label(\"Missing Subjects\") ) %>% build() tail(missing_subs) %>% select(-starts_with('ord')) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/denom.html","id":"adding-a-total-row","dir":"Articles","previous_headings":"","what":"Adding a ‘Total’ Row","title":"Totals, Missings, and Denominators","text":"addition missing counts, summaries require addition ‘Total’ row. Tplyr helper function add_total_row() ease process . Like things within Tplyr - particularly vignette - significant bit nuance . Much functionality similar set_missing_count(). ’re able specify different format total, specified, associated count layer’s format used. ’re able set sort value specify want total row sit. nuance comes two places: default, add_total_row() count missing values, can exclude values using count_missings parameter. Tplyr warn set_count_missing() denom_ignore set TRUE, add_total_row() count_missings set TRUE format contains percentage. ? denominator ignoring missing values ’re still counting total, percentage shown can exceed 100%. add_total_row() throw warning variable used, becomes ambiguous total calculated. can rectify using set_denoms_by(), allows user control exactly groups used form denominator. way totals presented add_total_row() align denominators specified set_denom_by() generate total rows match grouping denominator values. example , summarize age groups sex. denominators determined treatment group sex, since excluding values denominator, total row ends matching denominator used. ‘Missing’ row tells us number missing values, count_missings set TRUE, missing counts included total row. probably isn’t choose display things, ’re trying show flexibility built Tplyr. default text Total row “Total”, provide set_total_row_label() allow customize text used display. Let’s look practical version table . display missings, probably want exclude total. using set_missing_count(). commonly, ’ll see : Now table intuitive. used set_missing_count() update denominators, missing excluded. Now, total row intuitively matches denominators used within group, can see many missing records excluded. may stumbled upon portion vignette searching create total column. Tplyr allows well function add_total_group() read vignette(\"table\"). ’s denominators! Happy counting!","code":"tplyr_adsl2 <- tplyr_adsl tplyr_adsl2[sample(nrow(tplyr_adsl2), 50), \"AGEGR1\"] <- NA tplyr_table(tplyr_adsl2, TRT01P) %>% add_layer( group_count(AGEGR1, by=SEX) %>% set_denoms_by(TRT01P, SEX) %>% # This gives me a Total row each group add_total_row(f_str(\"xxx\", n), count_missings=TRUE, sort_value=-Inf) %>% set_total_row_label(\"All Age Groups\") %>% set_missing_count(f_str(\"xx (xx.x%)\", n, pct), Missing = NA, sort_value=Inf) ) %>% build() %>% arrange(ord_layer_1, ord_layer_2) %>% kable() tplyr_table(tplyr_adsl2, TRT01P) %>% add_layer( group_count(AGEGR1, by=SEX) %>% set_denoms_by(TRT01P, SEX) %>% # This gives me a Total row each group add_total_row(f_str(\"xxx\", n), count_missings=FALSE, sort_value=-Inf) %>% set_total_row_label(\"All Age Groups\") %>% set_missing_count(f_str(\"xxx\", n), Missing = NA, sort_value=Inf, denom_ignore=TRUE) ) %>% build() %>% arrange(ord_layer_1, ord_layer_2) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/desc.html","id":"built-in-summaries","dir":"Articles","previous_headings":"","what":"Built-in Summaries","title":"Descriptive Statistic Layers","text":"’ve built number default summaries Tplyr, allows perform summaries without specify functions calculate . summaries built Tplyr listed . second column names use within f_str() call use . third column, syntax used make function call.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/desc.html","id":"notes-about-built-ins","dir":"Articles","previous_headings":"Built-in Summaries","what":"Notes About Built-in’s","title":"Descriptive Statistic Layers","text":"Note non-default option used function calls na.rm=TRUE. ’s important note min max, na.rm=TRUE used vector NA, functions return Inf -Inf respectively. formatting numbers, unexpected also inconsistent descriptive statistic functions, return NA. Therefore, just min max, Inf’s converted NA ’ll align behavior empty parameter f_str(). Using default settings descriptive statistic functions typically fine, IQR, Q1, Q3 note several different quantile algorithms available R. default chose use R default Type 7: \\[ m = 1-p. p[k] = (k - 1) / (n - 1). \\textrm{case, } p[k] = mode[F(x[k])]. \\textrm{used S.} \\] said, still want offer flexibility , can change quantile algorithm switching tplyr.quantile_type option. ’re intending match SAS definition, can use Type 3. information, see stats::quantile() documentation. example demonstrates using default quantile algorithm R. next example demonstrates using quantile algorithm Type 3, matches SAS definition : \\[ \\textrm{Nearest even order statistic. γ = 0 g = 0 j even, 1 otherwise.} \\] ’s determine algorithm use - found necessary provide flexibility change within default summaries. Tplyr doesn’t offer summaries need?","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(CUMDOSE) %>% set_format_strings(\"Q1, Q3\" = f_str('xxxxx, xxxxx', q1, q3)) ) %>% build() %>% select(-starts_with(\"ord\")) %>% kable() options(tplyr.quantile_type = 3) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(CUMDOSE) %>% set_format_strings(\"Q1, Q3\" = f_str('xxxxx, xxxxx', q1, q3)) ) %>% build() %>% select(-starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/desc.html","id":"custom-summaries","dir":"Articles","previous_headings":"","what":"Custom Summaries","title":"Descriptive Statistic Layers","text":"understand defaults may cover every descriptive statistic ’d like see. ’s ’ve opened door creating custom summaries. Custom summaries allow provide function ’d like desc layer. can focus derivation calculate number want see. Tplyr can consume function, use existing tools within Tplyr produce string formatted result alongside default summaries provide well. Custom summaries may provided two ways: tplyr.custom_summaries option set session level function set_custom_summaries() layer level setting Tplyr, layer setting always take precedence setting. Let’s look example. , important things demonstrated: multi-variable descriptive statistics layer. AGE HEIGHTBL summarized layer. AGE results go var1_ variables HEIGHTBL results go var2_ variables. parameter names set_custom_summaries(), names left side equals, flow set_format_strings() f_str() calls. Just like default summaries, geometric_mean becomes name refer order use geometric mean derivation summary. geometric mean, target variable ’re summarizing referred .var. may seem intuitive. reason use .var , like example, custom function can applied separate target variables. Another note custom summaries ’re able overwrite default summaries built Tplyr well. Don’t like default summary functions provide? Use tplyr.custom_summaries option overwrite session, add new ones like include. example, use Tplyr default mean. now, let’s overwrite mean using custom summary. Let’s use trimmed mean instead, taking 20% observations ends. Note table code used produce output . Now Tplyr used custom summary function mean specified tplyr.custom_summaries option. Also note use rlang::quos(). ’ve done best mask user everywhere possible make interfaces clean intuitive, great deal Tplyr built using ‘rlang’ non-standard evaluation. Within option one instances user needs concern use quosures. ’d like learn non-standard evaluation quosures, recommend Section IV Advanced R.","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(vars(AGE, HEIGHTBL), by = \"Sepal Length\") %>% set_custom_summaries( geometric_mean = exp(sum(log(.var[.var > 0]), na.rm=TRUE) / length(.var)) ) %>% set_format_strings( 'Geometric Mean (SD)' = f_str('xx.xx (xx.xxx)', geometric_mean, sd) ) ) %>% build() %>% select(-starts_with(\"ord\")) %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE) %>% set_format_strings(\"Mean\" = f_str('xx.xx', mean)) ) %>% build() %>% kable() options(tplyr.custom_summaries = rlang::quos( mean = mean(.var, na.rm=TRUE, trim=0.4) ) ) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE) %>% set_format_strings(\"Mean\" = f_str('xx.xx', mean)) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/desc_layer_formatting.html","id":"empty-value-formatting","dir":"Articles","previous_headings":"","what":"Empty Value Formatting","title":"Advanced Descriptive Statistic Layer Formatting","text":"default, available value summary particular observation, result presented blanked . Note: Tplyr generally respects factor levels - instances missing row column group, factor level present, variable row still generate) Note entire example records var1_Placebo missing. Tplyr gives control fill space. Let’s say wanted instead make space say “Missing”. can control f_str() object using empty parameter. Look empty parameter . , use named character vector, name .overall. name used, elements within cell missing, filled specified text. Otherwise, provided string fill just missing parameter. cases, may ’d like see. Perhaps want string fills missing space. example , instead filling whole space, empty text “NA” replaces empty value element. ‘Mean (SD)’, now ‘NA ( NA)’. Note proper padding still used ‘NA’ make sure parentheses still align populated records.","code":"tplyr_adsl$TRT01P <- as.factor(tplyr_adsl$TRT01P) tplyr_adlb$TRTA <- as.factor(tplyr_adlb$TRTA) tplyr_adlb_2 <- tplyr_adlb %>% filter(TRTA != \"Placebo\") tplyr_table(tplyr_adlb_2, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01P) %>% add_layer( group_desc(AVAL, by=PARAMCD) %>% set_format_strings('Mean (SD)' = f_str('xxx (xxx)', mean, sd)) ) %>% build() %>% head() %>% select(-starts_with(\"ord\")) %>% kable() tplyr_table(tplyr_adlb_2, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01P) %>% add_layer( group_desc(AVAL, by=PARAMCD) %>% set_format_strings('Mean (SD)' = f_str('xxx.xx (xxx.xxx)', mean, sd, empty=c(.overall=\"MISSING\"))) ) %>% build() %>% head() %>% select(-starts_with(\"ord\")) %>% kable() tplyr_table(tplyr_adlb_2, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01P) %>% add_layer( group_desc(AVAL, by=PARAMCD) %>% set_format_strings('Mean (SD)' = f_str('xxx.xx (xxx.xxx)', mean, sd, empty=c(\"NA\"))) ) %>% build() %>% head() %>% select(-starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/desc_layer_formatting.html","id":"auto-precision","dir":"Articles","previous_headings":"","what":"Auto Precision","title":"Advanced Descriptive Statistic Layer Formatting","text":"may noticed approach formatting covered far leaves lot desired. Consider analyzing lab results, may want precision vary based collected precision tests. Furthermore, depending summary presented, may wish increase precision . example, may want mean collected precision +1 decimal place, standard deviation +2. Tplyr covered using auto-precision. Auto-precision allows format numeric summaries based precision data collected. built format strings, natural place specify desired format specify want data presented. wish use auto-precision, use instead x creating summaries. Note one needed side decimal. use increased precision, use +n n number additional spaces wish add. can see, decimal precision now varying depending test performed. Notice integer decimal side number fluctuate well. Tplyr collects integer decimal precision, can specify separately. example, use x’s specify default number spaces integers used consistently across variables, vary decimal precision based collected data. can also increment number spaces integer decimal separately. - kind ugly, isn’t ? really need 6 decimal places collected CA? reason, ’re able set cap precision ’s displayed: Now looks better. cap argument part set_format_strings(). need specify integer decimal caps separately. Note integer precision works slightly differently decimal precision. Integer precision relates length allotted left side decimal, integers truncate. using ‘x’ formatting, integer exceeds set length, push number . integer side auto-precision capped, necessary length integer associated group long necessary. Decimals, hand, round specified length. caps apply length allotted “” either integer decimal. example, decimal length capped 2 selected precision “+1”, 3 decimal places allotted. basic situation, ’re paying close attention, may questions. variables, like visit test. calculate precision visit test? collected precision different per visit don’t want ? multiple summary variables? determine precision ? modifier functions : Three variables summarized - AVAL, CHG, BASE. used precision? set_precision_on() allows specify , precision_on() variable must one variables within target_var. Similarly, set_precision_by() changes variables used determine collected precision. precision_on() variable specified, first variable target_var used. precision_by variables specified, default variables used.","code":"tplyr_table(tplyr_adlb, TRTA) %>% add_layer( group_desc(AVAL, by = PARAMCD) %>% set_format_strings( 'Mean (SD)' = f_str('a.a+1 (a.a+2)', mean, sd) ) ) %>% build() %>% head(20) %>% select(-starts_with(\"ord\")) %>% kable() tplyr_table(tplyr_adlb, TRTA) %>% add_layer( group_desc(AVAL, by = PARAMCD) %>% set_format_strings( 'Mean (SD)' = f_str('a.a+1 (a.a+2)', mean, sd), cap = c(int=3, dec=2) ) ) %>% build() %>% head(20) %>% select(-starts_with(\"ord\")) %>% kable() tplyr_table(tplyr_adlb, TRTA) %>% add_layer( group_desc(vars(AVAL, CHG, BASE), by = PARAMCD) %>% set_format_strings( 'Mean (SD)' = f_str('a.a+1 (a.a+2)', mean, sd, empty=\"NA\"), cap = c(int=3, dec=2) ) %>% set_precision_on(AVAL) %>% set_precision_by(PARAMCD) ) %>% build() %>% head() %>% select(-starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/desc_layer_formatting.html","id":"external-precision","dir":"Articles","previous_headings":"","what":"External Precision","title":"Advanced Descriptive Statistic Layer Formatting","text":"Lastly, dynamic precision might ’re looking , may want precision driven data. Perhaps ’s company standard dictates decimal precision used separate lab test. Maybe even deeper lab test category. New Tplyr 1.0.0 ’ve added ability take decimal precision external source. principal external precision exactly auto-precision. difference - user - provide precision table Tplyr automatically calculating background. done using new function set_precision_data(). output , Notice precision PARAMCD varies depending specified data frame prec_data. one variable groups missing precision data, Tplyr can default back using auto-precision using option default=auto.","code":"prec_data <- tibble::tribble( ~PARAMCD, ~max_int, ~max_dec, \"BUN\", 1, 0, \"CA\", 2, 4, \"CK\", 3, 1, \"GGT\", 3, 0, \"URATE\", 3, 1, ) tplyr_table(tplyr_adlb, TRTA) %>% add_layer( group_desc(AVAL, by = PARAMCD) %>% set_format_strings( 'Mean (SD)' = f_str('a.a+1 (a.a+2)', mean, sd, empty=\"NA\") ) %>% set_precision_on(AVAL) %>% set_precision_by(PARAMCD) %>% set_precision_data(prec_data) ) %>% build() %>% head() %>% select(-starts_with(\"ord\")) %>% kable() prec_data <- tibble::tribble( ~PARAMCD, ~max_int, ~max_dec, \"BUN\", 1, 0, \"CA\", 2, 4, \"CK\", 3, 1, \"GGT\", 3, 0, ) tplyr_table(tplyr_adlb, TRTA) %>% add_layer( group_desc(AVAL, by = PARAMCD) %>% set_format_strings( 'Mean (SD)' = f_str('a.a+1 (a.a+2)', mean, sd, empty=\"NA\") ) %>% set_precision_on(AVAL) %>% set_precision_by(PARAMCD) %>% set_precision_data(prec_data, default=\"auto\") ) %>% build() %>% head() %>% select(-starts_with(\"ord\")) %>% kable() #> Unhandled precision cases were found - calculating precision based on source data"},{"path":"https://atorus-research.github.io/Tplyr/articles/desc_layer_formatting.html","id":"parenthesis-hugging","dir":"Articles","previous_headings":"","what":"Parenthesis Hugging","title":"Advanced Descriptive Statistic Layer Formatting","text":"default, using ‘x’ ‘’, character within format string stay stationary. Consider standard example descriptive statistic layer vignette. Note certain number integers alotted, space left numbers fill space, position parenthesis stays fixed. displays, may want parenthesis ‘hug’ number - “format group” width stay fixed, parenthesis move right along numbers consuming less integer space. Within f_str(), can achieve using capital ‘X’. example, focusing mean standard deviation line: Similarly, functionality works auto precision using capital . two rules using ‘parenthesis hugging’: Capital letters used integer side number character must precede capital letter, otherwise ’s character ‘hug’ Aside rules, parenthesis hugging can combined valid format string capabilities.","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE, by = \"Age (years)\", where= SAFFL==\"Y\") %>% set_format_strings( \"n\" = f_str(\"xx\", n), \"Mean (SD)\"= f_str(\"xx.x (xx.xx)\", mean, sd), \"Median\" = f_str(\"xx.x\", median), \"Q1, Q3\" = f_str(\"xx, xx\", q1, q3), \"Min, Max\" = f_str(\"xx, xx\", min, max), \"Missing\" = f_str(\"xx\", missing) ) ) %>% build() %>% select(-starts_with('ord')) #> # A tibble: 6 × 5 #> row_label1 row_label2 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 Age (years) n \"86\" \"84\" #> 2 Age (years) Mean (SD) \"75.2 ( 8.59)\" \"74.4 ( 7.89)\" #> 3 Age (years) Median \"76.0\" \"76.0\" #> 4 Age (years) Q1, Q3 \"69, 82\" \"71, 80\" #> 5 Age (years) Min, Max \"52, 89\" \"56, 88\" #> 6 Age (years) Missing \" 0\" \" 0\" #> # ℹ 1 more variable: `var1_Xanomeline Low Dose` tplyr_table(tplyr_adlb, TRTA, PARAMCD == \"CK\") %>% add_layer( group_desc(AVAL, by=vars(PARAMCD, AVISIT)) %>% set_format_strings( TEST = f_str(\"xxx.x (XXX.x)\", mean, sd, empty=\"NA\") ) %>% set_precision_by(PARAMCD) ) %>% build() %>% head() %>% select(-starts_with('ord')) #> # A tibble: 3 × 6 #> row_label1 row_label2 row_label3 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 CK Week 12 TEST 140.0 (148.6) \"140.1 (115.5)\" #> 2 CK Week 24 TEST 246.6 (438.5) \" 55.5 (3.5)\" #> 3 CK Week 8 TEST 116.0 (78.9) \" 93.3 (80.6)\" #> # ℹ 1 more variable: `var1_Xanomeline Low Dose` tplyr_table(tplyr_adlb, TRTA, PARAMCD == \"CK\") %>% add_layer( group_desc(AVAL, by=vars(PARAMCD, AVISIT)) %>% set_format_strings( TEST = f_str(\"a.a (A.a)\", mean, sd, empty=\"NA\") ) %>% set_precision_by(PARAMCD) ) %>% build() %>% head() %>% select(-starts_with('ord')) #> # A tibble: 3 × 6 #> row_label1 row_label2 row_label3 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 CK Week 12 TEST \" 140 (149)\" \" 140 (115)\" #> 2 CK Week 24 TEST \" 247 (438)\" \" 56 (4)\" #> 3 CK Week 8 TEST \" 116 (79)\" \" 93 (81)\" #> # ℹ 1 more variable: `var1_Xanomeline Low Dose` "},{"path":"https://atorus-research.github.io/Tplyr/articles/general_string_formatting.html","id":"format-strings","dir":"Articles","previous_headings":"","what":"Format Strings","title":"General String Formatting","text":"Regardless layer type use within Tplyr, control formatting handled using format strings. Consider following example. layer type, want configure string formatting use function set_format_strings(). Inside set_format_strings() provide f_str() objects. Within count layers, basic tables can just provide singe f_str() object control general formatting. descriptive statistic layers, provide named parameters, names become values row_label1 statistics provided within f_str() object. Regardless layer type, f_str() object controls numbers reported resulting table. table outlines variables available within layer. Note: actual equations used descriptive statistics layers, see vignettes(\"desc\")","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE) %>% set_format_strings( f_str(\"xx (xx.x%)\", n, pct) ) ) %>% add_layer( group_desc(AGE) %>% set_format_strings( \"Mean (SD)\" = f_str(\"xx.x (xx.xx)\", mean, sd) ) ) %>% build() %>% select(1:3) #> # A tibble: 4 × 3 #> row_label1 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 AMERICAN INDIAN OR ALASKA NATIVE \" 0 ( 0.0%)\" \" 1 ( 1.2%)\" #> 2 BLACK OR AFRICAN AMERICAN \" 8 ( 9.3%)\" \" 9 (10.7%)\" #> 3 WHITE \"78 (90.7%)\" \"74 (88.1%)\" #> 4 Mean (SD) \"75.2 ( 8.59)\" \"74.4 ( 7.89)\""},{"path":"https://atorus-research.github.io/Tplyr/articles/general_string_formatting.html","id":"general-formatting","dir":"Articles","previous_headings":"","what":"General Formatting","title":"General String Formatting","text":"Looking back Tplyr table , let’s look count layer’s f_str() call. can see print method f_str() object capture “format string”, xx (xx.x%), metadata surrounding . string details exactly numbers placed within output result result look like. done breaking string “format groups”, separate numeric fields surrounding characters within format string. format string, xx (xx.x%), two different format groups. first field xx, attaches variable n. second (xx.x%), attaches variable pct. result formatted, first format group, xx, output total width 2 characters, space 2 integers. second format group output total width 7 characters, space 2 integers 1 decimal place. final result, two fields concatenated together, total width string consistently 10 characters. Note though formatting truncate integers, instead total width string expanded, skewing alignment. Decimal points always rounded specified precision.","code":"f_str(\"xx (xx.x%)\", n, pct) #> *** Format String *** #> xx (xx.x%) #> *** vars, extracted formats, and settings *** #> n formated as: xx #> integer length: 2 #> decimal length: 0 #> pct formated as: xx.x #> integer length: 2 #> decimal length: 1 #> Total Format Size: 10"},{"path":"https://atorus-research.github.io/Tplyr/articles/general_string_formatting.html","id":"controlling-formatting","dir":"Articles","previous_headings":"","what":"Controlling Formatting","title":"General String Formatting","text":"Note format string, result numbers formatted fill spaces x’s. characters string preserved . Tplyr’s format strings different valid characters specifically control numeric fields.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/general_string_formatting.html","id":"lowercase-x","dir":"Articles","previous_headings":"Controlling Formatting","what":"Lowercase ‘x’","title":"General String Formatting","text":"detailed first example, using lower case ‘x’, exact width space allotted x’s preserved. Note var1_Placebo row . integer width n counts space right opening parenthesis pct field preserved. guarentees (using monospace font) non-numeric characters within format strings remain place. Given integers don’t truncate, spaces undesired, integers automatically increase width. example , n pct result exceeds 10, width output string automatically expands. can trigger behaivor using single ‘x’ integer side format group.","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE) %>% set_format_strings( f_str(\"xx (xx.x%)\", n, pct) ) ) %>% build() %>% select(1:3) #> # A tibble: 3 × 3 #> row_label1 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 AMERICAN INDIAN OR ALASKA NATIVE \" 0 ( 0.0%)\" \" 1 ( 1.2%)\" #> 2 BLACK OR AFRICAN AMERICAN \" 8 ( 9.3%)\" \" 9 (10.7%)\" #> 3 WHITE \"78 (90.7%)\" \"74 (88.1%)\" tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE) %>% set_format_strings( f_str(\"x (x.x%)\", n, pct) ) ) %>% build() %>% select(1:3) #> # A tibble: 3 × 3 #> row_label1 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 AMERICAN INDIAN OR ALASKA NATIVE 0 (0.0%) 1 (1.2%) #> 2 BLACK OR AFRICAN AMERICAN 8 (9.3%) 9 (10.7%) #> 3 WHITE 78 (90.7%) 74 (88.1%)"},{"path":"https://atorus-research.github.io/Tplyr/articles/general_string_formatting.html","id":"uppercase-x","dir":"Articles","previous_headings":"Controlling Formatting","what":"Uppercase ‘X’","title":"General String Formatting","text":"downside last example alignment format groups completely lost. parenthesis pct field now bound integer percent value, entire string shifted right. Tplyr offers customization using concept called “parenthesis hugging”. triggered using uppercase ‘X’ integer side format group. Consider following example: Now total string width preserved properly. change instead pulling right side format group , essentially aligning left format group, parenthesis moved right towards integer side pct field, “hugging” numeric results percent. two rules using ‘parenthesis hugging’: Capital letters used integer side number character must precede capital letter, otherwise ’s character ‘hug’","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE) %>% set_format_strings( f_str(\"xx (XX.x%)\", n, pct) ) ) %>% build() %>% select(1:3) #> # A tibble: 3 × 3 #> row_label1 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 AMERICAN INDIAN OR ALASKA NATIVE \" 0 (0.0%)\" \" 1 (1.2%)\" #> 2 BLACK OR AFRICAN AMERICAN \" 8 (9.3%)\" \" 9 (10.7%)\" #> 3 WHITE \"78 (90.7%)\" \"74 (88.1%)\""},{"path":"https://atorus-research.github.io/Tplyr/articles/general_string_formatting.html","id":"auto-precision","dir":"Articles","previous_headings":"","what":"Auto-precision","title":"General String Formatting","text":"Lastly, Tplyr also capability automatically determine widths necessary format strings. done using character ‘’ instead ‘x’ format string. Consider following example. Note decimal precision varies different lab test results. feature beneficial decimal precision rules must based precision data collected. information auto-precision descriptive statistics layers, see vignette(\"desc_layer_formatting\"). count layers, auto-precision can also used surrounding n counts. example, default format string counts layers Tplyr set (xxx.x%). auto-format n result based maximum summarized value n within data. example: Given maximum count >=10 <100, integer width n assigned 2. Note auto-precision percents auto-format based available percentages. count filled based n result. layer types, capital follows logic X, triggered using auto-precision. Take example adverse event table: go format group: distinct n count spaced based width maximum n value percent field maximum width 2 characters, opening parenthesis hug integer percent value right event counts within brackets ([]) auto formatted based maximum n value, opening bracket hug n count right. vignette focused specifics formatting using f_str() objects. details layer specifics, check individual layer vignettes.","code":"tplyr_table(tplyr_adlb, TRTA, where=PARAMCD %in% c(\"CA\", \"URATE\")) %>% add_layer( group_desc(AVAL, by=vars(PARAMCD, AVISIT)) %>% set_format_strings( 'Mean (SD)' = f_str('a.a (a.a+1)', mean, sd) ) %>% set_precision_by(PARAMCD) ) %>% build() %>% select(1:5) #> # A tibble: 6 × 5 #> row_label1 row_label2 row_label3 var1_Placebo var1_Xanomeline High Dos…¹ #> #> 1 CA Week 12 Mean (SD) 2.19144 (0.074711) 2.18134 (0.062553) #> 2 CA Week 24 Mean (SD) 2.16838 (0.046617) 2.18063 (0.099174) #> 3 CA Week 8 Mean (SD) 2.19144 (0.102771) 2.23926 (0.199489) #> 4 URATE Week 12 Mean (SD) 298.887 (105.3868) 304.835 ( 85.1772) #> 5 URATE Week 24 Mean (SD) 269.643 (111.8899) 281.539 (126.6612) #> 6 URATE Week 8 Mean (SD) 234.946 ( 45.8806) 273.608 ( 36.6659) #> # ℹ abbreviated name: ¹​`var1_Xanomeline High Dose` tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE) %>% set_format_strings(f_str(\"a (xxx.x%)\", n, pct)) ) %>% build() %>% select(1:3) #> # A tibble: 3 × 3 #> row_label1 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 AMERICAN INDIAN OR ALASKA NATIVE \" 0 ( 0.0%)\" \" 1 ( 1.2%)\" #> 2 BLACK OR AFRICAN AMERICAN \" 8 ( 9.3%)\" \" 9 ( 10.7%)\" #> 3 WHITE \"78 ( 90.7%)\" \"74 ( 88.1%)\" tplyr_table(tplyr_adae, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% add_layer( group_count(AEDECOD) %>% set_format_strings(f_str(\"a (XX.x%) [A]\", distinct_n, distinct_pct, n)) %>% set_distinct_by(USUBJID) ) %>% build() %>% select(1:3) #> # A tibble: 21 × 3 #> row_label1 var1_Placebo `var1_Xanomeline High Dose` #> #> 1 ACTINIC KERATOSIS \" 0 (0.0%) [0]\" \" 1 (1.2%) [1]\" #> 2 ALOPECIA \" 1 (1.2%) [1]\" \" 0 (0.0%) [0]\" #> 3 BLISTER \" 0 (0.0%) [0]\" \" 1 (1.2%) [2]\" #> 4 COLD SWEAT \" 1 (1.2%) [3]\" \" 0 (0.0%) [0]\" #> 5 DERMATITIS ATOPIC \" 1 (1.2%) [1]\" \" 0 (0.0%) [0]\" #> 6 DERMATITIS CONTACT \" 0 (0.0%) [0]\" \" 0 (0.0%) [0]\" #> 7 DRUG ERUPTION \" 1 (1.2%) [1]\" \" 0 (0.0%) [0]\" #> 8 ERYTHEMA \" 9 (10.5%) [13]\" \"14 (16.7%) [22]\" #> 9 HYPERHIDROSIS \" 2 (2.3%) [2]\" \" 8 (9.5%) [10]\" #> 10 PRURITUS \" 8 (9.3%) [11]\" \"26 (31.0%) [38]\" #> # ℹ 11 more rows"},{"path":"https://atorus-research.github.io/Tplyr/articles/layer_templates.html","id":"basic-templates","dir":"Articles","previous_headings":"","what":"Basic Templates","title":"Layer Templates","text":"functions new_layer_template() use_template() allow user create use layer templates. Layer templates allow user pre-build reuse entire layer configuration, layer constructor modifying functions. Furthermore, users can specify parameters may want interchangeable. Additionally, layer templates extensible, template can use extended additional layer modifying functions. Consider following example: example, ’ve created basic layer template. template named “example_template”, name ’ll use reference template want use . template created, start function group_count(...). Note use ellipsis (.e. ...). required part layer template. Templates must start Tplyr layer constructor, one function group_count(), group_desc(), group_shift(). ellipsis necessary template used, able pass arguments directly layer constructor. example: Within use_template(), first parameter template name. , supply arguments normally group_count(), group_desc(), group_shift(). Additionally, note formats applied just used set_format_strings() specified template. template applied, table built settings appropriately. additional feature layer templates act just function Tplyr layer. means ’re also extensible can expanded directly within Tplyr table. example: show two things - first, called template without variable argument previous example. allows template flexibility depending context usage. Furthermore, added additional modifier function add_total_row(). example, took layer constructed template modified layer . may useful layer reusable. reusable portions can put template, rest added using normal Tplyr syntax.","code":"new_layer_template( \"example_template\", group_count(...) %>% set_format_strings(f_str(\"xx (xx%)\", n, pct)) ) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( use_template(\"example_template\", RACE, by=ETHNIC) ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( use_template(\"example_template\", RACE) %>% add_total_row() ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/layer_templates.html","id":"templates-with-parameters","dir":"Articles","previous_headings":"Basic Templates","what":"Templates With Parameters","title":"Layer Templates","text":"’s also possible add interchangeable parameters layer template beyond group constructor arguments. requires special syntax. Consider following template: example, create template similar first example. now add two modifying functions, set_order_count_method() set_ordering_cols(). Within functions, ’ve supplied interchangeable parameters template function, sort_meth sort_col. Tplyr layer template, parameters supplied using curly brackets (.e. {}). specify arguments using templater, use use_template() argument add_params. example: add_params parameter, must supply list. list must also named, element names (example, sort_meth sort_col) match parameter names template . ’s mismatch template’s parameters parameters provided add_params, encounter error. values supplied add_param exactly arguments supply matching field within template (.e. ’s extra quoting using quo() necessary pass symbol).","code":"new_layer_template(\"example_params\", group_count(...) %>% set_format_strings(f_str(\"xx (xx.x%)\", n, pct)) %>% set_order_count_method({sort_meth}) %>% set_ordering_cols({sort_col}) ) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( use_template('example_params', RACE, add_params = list( sort_meth = \"bycount\", sort_col = Placebo )) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/layer_templates.html","id":"viewing-and-removing-templates","dir":"Articles","previous_headings":"","what":"Viewing and Removing Templates","title":"Layer Templates","text":"want view available templates session, use function get_layer_templates(). can view specific template using get_layer_template(). Note layer templates class tplyr_layer_template. additionally carry attribute params specifies parameters available template, can seen output . Finally, want remove layer session, use function remove_layer_template()","code":"get_layer_templates() #> $example_template #> Template name: example_template #> Template parameters: None #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx%)\", n, pct)) #> } #> #> $example_params #> Template name: example_params #> Template parameters: sort_meth, sort_col #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx.x%)\", n, pct)) %>% set_order_count_method({ #> sort_meth #> }) %>% set_ordering_cols({ #> sort_col #> }) #> } get_layer_template(\"example_params\") #> Template name: example_params #> Template parameters: sort_meth, sort_col #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx.x%)\", n, pct)) %>% set_order_count_method({ #> sort_meth #> }) %>% set_ordering_cols({ #> sort_col #> }) #> } remove_layer_template(\"example_params\") get_layer_templates() #> $example_template #> Template name: example_template #> Template parameters: None #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx%)\", n, pct)) #> }"},{"path":"https://atorus-research.github.io/Tplyr/articles/metadata.html","id":"generating-the-metadata","dir":"Articles","previous_headings":"","what":"Generating the Metadata","title":"Tplyr Metadata","text":"Consider following example: trigger creation metadata, build() function new argument metadata. specifying TRUE, underlying metadata within Tplyr prepared extractable format. action user needs specify action take place. metadata argument used, new column produced output dataframe called row_id. row_id variable provides persistent reference row interest, even output dataframe sorted. review vignette(\"styled-table\"), note expect certain amount post processing styling built data frame Tplyr, let use whatever packages prefer. , reference ID necessary.","code":"t <- tplyr_table(tplyr_adsl, TRT01P, where = SAFFL == \"Y\") %>% add_layer( group_count(RACE) ) %>% add_layer( group_desc(AGE, where = EFFFL == \"Y\") ) dat <- t %>% build(metadata=TRUE) kable(dat)"},{"path":"https://atorus-research.github.io/Tplyr/articles/metadata.html","id":"extracting-the-input-source","dir":"Articles","previous_headings":"","what":"Extracting The Input Source","title":"Tplyr Metadata","text":", let’s cut chase. likely way use metadata pull source data created cell. , ’ve provided function get_meta_subset(). information need row_id column name result cell interest. example, looking result , want know 8 subjects Placebo group Black African American: using row_id column, dataframe pulled right us. Notice USUBJID included default, even though Tplyr ’s reference anywhere tplyr_table() variable USUBJID. get_meta_subset() additional argument add_cols allows specify additional columns want included resulting dataframe, default USUBJID. let’s say want additionally include variable SEX. Variables provided using dplyr::vars(), just like cols argument tplyr_table() arguments layer type. mentioned, input source data can extracted result cell created Tplyr. let’s say want know subjects relevant descriptive statistics around age Xanomeline High Dose group: Note: Trimmed space Notice columns returned different. First , within summary , pulled results descriptive statistics layer. target variable layer AGE, AGE returned resulting output. Additionally, layer level argument used subset EFFFL == \"Y\", leads EFFFL included output well.","code":"get_meta_subset(t, 'c2_1', 'var1_Placebo') %>% kable() get_meta_subset(t, 'c2_1', 'var1_Placebo', add_cols = vars(USUBJID, SEX)) %>% kable() get_meta_subset(t, 'd1_2', 'var1_Xanomeline High Dose') %>% head(10) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/metadata.html","id":"extracting-a-result-cells-metadata","dir":"Articles","previous_headings":"","what":"Extracting a Result Cell’s Metadata","title":"Tplyr Metadata","text":"extract dataframe get_meta_subset(), metadata result cell needs first extracted. metadata can directly accessed using function get_meta_result(). Using last example get_meta_subset() : resulting output new object Tplyr called tplyr_meta(). container relevent metadata specific result. object list two elements: names filters. names element contains quosures variable relevant specific result. include target variable, variables used layer, cols variables used table, variables included filter condition relevant create result. filters element contains filter condition (provided calls) necessary create particular cell. include table level argument, layer level argument, filter condition specific value variable cols variable necessary create cell, similarly filter treatment group interest. results provided can unpacked directly dplyr syntax necessary, exactly happens get_meta_subset(). example: Note: Trimmed space - says can’t let imagination run wild?","code":"get_meta_result(t, 'd1_2', 'var1_Xanomeline High Dose') #> tplyr_meta: 4 names, 3 filters #> Names: #> TRT01P, EFFFL, SAFFL, AGE #> Filters: #> TRT01P == c(\"Xanomeline High Dose\"), EFFFL == \"Y\", SAFFL == \"Y\" m <- get_meta_result(t, 'd1_2', 'var1_Xanomeline High Dose') tplyr_adsl %>% filter(!!!m$filters) %>% select(!!!m$names) %>% head(10) %>% kable() cat(c(\"tplyr_adsl %>%\\n\", \" filter(\\n \", paste(purrr::map_chr(m$filters, ~ rlang::as_label(.)), collpase=\",\\n \"), \") %>%\\n\", paste(\" select(\", paste(purrr::map_chr(m$names, rlang::as_label), collapse=\", \"), \")\", sep=\"\") ))"},{"path":"https://atorus-research.github.io/Tplyr/articles/metadata.html","id":"anti-joins","dir":"Articles","previous_headings":"Extracting a Result Cell’s Metadata","what":"Anti Joins","title":"Tplyr Metadata","text":"data presented within table refers back target dataset data summarized. cases, data presented may refer information excluded summary. case use Tplyr function add_missing_subjects_row(). case, counts presented refer data excluded target present population data. metadata thus needs refer excluded data. handle , ’s additional field called ‘Anti Join’. Consider example: missing row example counts subjects within respective treatment groups adverse events body system “SKIN SUBCUTANEOUS TISSUE DISORDERS”. ’s metadata result Placebo treatment group looks like. result addition field ‘Anti-join’. element two fields, join metadata, “” field, specifies merging variable used “anti-joining” target data. join metadata refers data interest population data. Note metadata target data variable names filter conditions referring AEBODSYS AEDECOD, variables present within join metadata, information present within population data. usual joins work focus overlap two sets, anti-join looks non-overlap. metadata provided specifically give us “subjects within Placebo treatment group adverse event within body system ‘SKIN SUBCUTANEOUS TISSUE DISORDERS’”. Extracting metadata works much way extracting results. ’re working tplyr_table object, ’s additional information need provide function.","code":"t <- tplyr_table(tplyr_adae, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) %>% set_distinct_by(USUBJID) %>% add_missing_subjects_row(f_str(\"xx (XX.x%)\", distinct_n, distinct_pct), sort_value = Inf) ) x <- build(t, metadata=TRUE) tail(x) %>% select(starts_with('row'), var1_Placebo) %>% kable() m <- get_meta_result(t, 'c23_1', 'var1_Placebo') m #> tplyr_meta: 3 names, 4 filters #> Names: #> TRTA, AEBODSYS, AEDECOD #> Filters: #> TRTA == c(\"Placebo\"), AEBODSYS == c(\"SKIN AND SUBCUTANEOUS TISSUE DISORDERS\"), TRUE, TRUE #> Anti-join: #> Join Meta: #> tplyr_meta: 1 names, 3 filters #> Names: #> TRT01A #> Filters: #> TRT01A == c(\"Placebo\"), TRUE, TRUE #> On: #> USUBJID head(get_meta_subset(t, 'c23_1', 'var1_Placebo')) #> # A tibble: 6 × 2 #> USUBJID TRT01A #> #> 1 01-701-1015 Placebo #> 2 01-701-1047 Placebo #> 3 01-701-1118 Placebo #> 4 01-701-1153 Placebo #> 5 01-701-1203 Placebo #> 6 01-701-1234 Placebo head(get_meta_subset(t$metadata, 'c23_1', 'var1_Placebo', target=t$target, pop_data=t$pop_data)) #> # A tibble: 6 × 2 #> USUBJID TRT01A #> #> 1 01-701-1015 Placebo #> 2 01-701-1047 Placebo #> 3 01-701-1118 Placebo #> 4 01-701-1153 Placebo #> 5 01-701-1203 Placebo #> 6 01-701-1234 Placebo tplyr_adsl %>% filter( TRTA == c(\"Placebo\") , AEBODSYS == c(\"SKIN AND SUBCUTANEOUS TISSUE DISORDERS\") , TRUE , TRUE , ) %>% select(TRTA, AEBODSYS, AEDECOD)"},{"path":"https://atorus-research.github.io/Tplyr/articles/metadata.html","id":"so-what-does-this-get-me","dir":"Articles","previous_headings":"","what":"So, What Does This Get Me?","title":"Tplyr Metadata","text":"get get metadata around result cell, can get exact results result cell. just need row ID column name. - get ? can query tables - ’s great. use . idea behind really support Shiny. Consider minimal application. Click result cells within table see happens. Source code available ’s . persistent row_id column selection enables use something like Shiny automatically query cell based position table. Using click events package like reactable, can pick row column selected pass information get_meta_result(). get resulting data frame, ’s , world Shiny tip fingers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/options.html","id":"default-layer-formats","dir":"Articles","previous_headings":"","what":"Default Layer Formats","title":"Tplyr Options","text":"Declaring string formats summaries need performed one verbose parts Tplyr. Furthermore, something often fairly consistent within study, ’ll likely want look across consistent set descriptive statistics, count/shift tables likely require sort “n (%)” formatting. Using format options similar setting string format. difference need enter string formats named list instead separate parameters function call. can see Tplyr picks option changes. table , didn’t use set_format_strings() anywhere - instead let Tplyr pick default formats options. One important thing understand options work particular scoping. Tplyr options broadest scope, work across entire session table. Setting formats tplyr_table() level override Tplyr options extends layer specified type current table. Setting formats tplyr_layer() level always prioritized Tplyr options tplyr_table() formats set. narrowest scope always used specified. demonstrate, consider following. Tplyr options remain set block . output: descriptive statistics layer “Age (Years)” uses specified table default using set_desc_layer_formats() first count layer “Categorical Age Groups” uses specified table default using set_count_layer_formats() second count layer “Ethnicity” uses layer level format specified using set_format_strings() outputs ignores Tplyr option defaults.","code":"options( # Count layer defaults tplyr.count_layer_default_formats = list(n_counts = f_str(\"xxx (xx%)\", n, pct), riskdiff = f_str('xx.xxx', dif) ), # Desc layer defaults tplyr.desc_layer_default_formats = list(\"n\" = f_str(\"xxx\", n), \"Mean (SD)\"= f_str(\"a.a+1 (a.a+2)\", mean, sd), \"Median\" = f_str(\"a.a+4\", median) ), # Shift layer defaults tplyr.shift_layer_default_formats = list(f_str(\"xxx\", n)) ) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE, by = \"Age (years)\") ) %>% add_layer( group_count(AGEGR1, by = \"Categorical Age Groups\") ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P) %>% set_count_layer_formats(n_counts = f_str(\"xx (xxx%)\", n, pct)) %>% set_desc_layer_formats(\"Mean (SD)\" = f_str(\"a.a+1 (a.a+2)\", mean, sd)) %>% add_layer( group_desc(AGE, by = \"Age (Years)\") ) %>% add_layer( group_count(AGEGR1, by = \"Categorical Age Groups\") ) %>% add_layer( group_count(ETHNIC, by = \"Ethnicity\") %>% set_format_strings(f_str(\"xxxxx (xx.xxx%)\", n, pct)) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/options.html","id":"precision-cap","dir":"Articles","previous_headings":"","what":"Precision Cap","title":"Tplyr Options","text":"Tplyr defaults avoiding capping precision. capping precision conscious decision, user specifically set limit many decimal places relevant specific result. One way cap precision using cap parameter within set_format_strings(). perhaps specific limit ’d like see output. , offer tplyr.precision_cap option set whatever cap wish. Similar layer defaults, setting precision cap layer level override tplyr.precision_cap option. layers example summarizing data. top layer using tplyr.precision_cap option set , limits 2 integer place 2 decimal places. bottom layer applies cap override option. Recall things auto precision: Integers truncated - rather, auto precision default much padding applied. number exceeds number spaces, length extended (.e. 2 integer places allotted, 100 still consume 3 places). cap applies spaces allotted ‘’. cap 2, ‘+1’ exceed 3 spaces. bottom layer overrides Tplyr option. Instead, integers capped 1 space, decimals capped 0.","code":"options(tplyr.precision_cap = c('int'=2, 'dec'=2)) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(HEIGHTBL, by = \"Height at Baseline\") %>% set_format_strings( 'Mean (SD)' = f_str('a.a (a.a+1)', mean, sd) ) ) %>% add_layer( group_desc(HEIGHTBL, by = \"Height at Baseline (Limited)\") %>% set_format_strings( 'Mean (SD)' = f_str('a.a (a.a+1)', mean, sd), cap = c('int'= 1, 'dec'=0) ) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/options.html","id":"custom-summaries","dir":"Articles","previous_headings":"","what":"Custom Summaries","title":"Tplyr Options","text":"Custom summaries allow extend capabilities descriptive statistics layers Tplyr. Maybe defaults don’t work ’d like , maybe custom functions within organization commonly like use. Specifying custom summaries wish use every table prove quite tedious - therefore, tplyr.custom_summaries option better choice. Note table code used produce output . Now Tplyr used custom summary function geometric_mean specified tplyr.custom_summaries option. Also note use rlang::quos(). ’ve done best mask user everywhere possible make interfaces clean intuitive, great deal Tplyr built using ‘rlang’ non-standard evaluation. Within option one instances user needs concern use quosures. ’d like learn non-standard evaluation quosures, recommend Section IV Advanced R. Now geometric mean set within Tplyr options, can use within descriptive statistics layers, just like one built-summaries.","code":"options(tplyr.custom_summaries = rlang::quos( geometric_mean = exp(sum(log(.var[.var > 0]),na.rm=TRUE) / length(.var)) )) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(AGE) %>% set_format_strings('Geometric Mean' = f_str('xx.xx', geometric_mean)) ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/options.html","id":"scientific-notation","dir":"Articles","previous_headings":"","what":"Scientific Notation","title":"Tplyr Options","text":"default, R switch scientific notation number less .001. controlled scipen option. default value scipen 0. ’d like increase decimal places required scientific notation triggered, increase value scipen. value scipen number orders ten smaller (.e. decimal places preceded 0’s) required switch scientific notation. Decreasing value scipen cause R switch scientific location larger numbers. easier understand example. Tplyr, option tplyr.scipen. scipen setting used Tplyr table built. allows use different scipen setting within Tplyr R session. default value use Tplyr 9999, intended totally prevent numbers switching scientific notation. want conscious decision make order prevent unexpected outputs. Note risk-difference variables mostly shifted scientific notation. limit shifted .1 within Tplyr build.","code":"options(scipen = 0) # This is the default .0001 #> [1] 1e-04 options(scipen = 1) # Require 5 decimal places instead .0001 #> [1] 0.0001 .00001 #> [1] 1e-05 options(scipen = -1) # Only require 3 decimal places .001 #> [1] 1e-03 options(tplyr.scipen = -3) t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% add_risk_diff(c('Xanomeline Low Dose', 'Placebo')) ) suppressWarnings(build(t)) %>% # Chi-squared warnings occur with small samples head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/options.html","id":"quantile-algorithms","dir":"Articles","previous_headings":"","what":"Quantile Algorithms","title":"Tplyr Options","text":"many algorithms available compute quantile R 9, controlled type parameter quantile(). descriptive statistics offer built-summaries Q1, Q3, Interquartile range, three use quantile() underlying implementation. Given offer default, felt important offer flexibility change algorithm. can tplyr.quantile_type. default chose use R default Type 7: \\[ m = 1-p. p[k] = (k - 1) / (n - 1). \\textrm{case, } p[k] = mode[F(x[k])]. \\textrm{used S.} \\] example demonstrates using default quantile algorithm R Within clinical world, may wish match way SAS calculates quantiles. match SAS’s definition, use Type 3: \\[ \\textrm{Nearest even order statistic. γ = 0 g = 0 j even, 1 otherwise.} \\]","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(CUMDOSE) %>% set_format_strings(\"Q1, Q3\" = f_str('xxxxx, xxxxx', q1, q3)) ) %>% build() %>% kable() options(tplyr.quantile_type = 3) tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_desc(CUMDOSE) %>% set_format_strings(\"Q1, Q3\" = f_str('xxxxx, xxxxx', q1, q3)) ) %>% build() %>% select(-starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/options.html","id":"ibm-rounding","dir":"Articles","previous_headings":"","what":"IBM Rounding","title":"Tplyr Options","text":"certain cases users may want match tables produced languages IBM rounding.Tplyr offers option ‘tplyr.IBMRounding’ change default rounding behavior Tplyr tables. Review var1_4 tables . Using default R behavior Using IBM rounding","code":"tplyr_table(mtcars, gear) %>% add_layer( group_desc(qsec) %>% set_format_strings(mean = f_str(\"xx.xx\", mean)) ) %>% build() #> # A tibble: 1 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 mean 17.69 18.96 15.64 1 1 withr::with_options( list(tplyr.IBMRounding = TRUE), { tplyr_table(mtcars, gear) %>% add_layer( group_desc(qsec) %>% set_format_strings(mean = f_str(\"xx.xx\", mean)) ) %>% build() } ) #> Warning: You have enabled IBM Rounding. This is an experimental feature. #> • If you have feedback please get in touch with the maintainers! #> This warning is displayed once every 8 hours. #> # A tibble: 1 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 mean 17.69 18.97 15.64 1 1"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"string-wrapping","dir":"Articles","previous_headings":"","what":"String wrapping","title":"Post-Processing","text":"Certain types output formats don’t elegantly handle string wrapping text. formats, simply width text word wraps. formats, LaTex outputs PDF (depending rendering engine) may wrap white space fine, words whose character length longer allotted width may print wider table cell. address , Tplyr ’ve added function str_indent_wrap(). largely built top function stringr::str_wrap() preserve much efficiency possible, two issues common clinical outputs addressed: Preceding indentation word preserved. example, nested adverse event table, preferred term indented, function wrap preserve words indentation new line. Words exceed specified width wrapped hyphenation. post-processing function, note function works tibble data.frame object, Tplyr table. Let’s look example. Note: ’re viewing data frame output HTML based outputs eliminate duplicate white spaces, makes difficult see things like padded indentation","code":"dat <- tibble( row_label1 = c(\"RENAL AND URINARY DISORDERS\", \" NEPHROLITHIASIS\"), var1_Placebo = c(\" 5 (50.0%)\", \" 3 (30.0%)\") ) dat %>% mutate( row_label1 = str_indent_wrap(row_label1, width = 10) ) #> # A tibble: 2 × 2 #> row_label1 var1_Placebo #> #> 1 \"RENAL AND\\nURINARY\\nDISORDERS\" \" 5 (50.0%)\" #> 2 \" NEPHROLIT-\\n HIASIS\" \" 3 (30.0%)\""},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"row-masking","dir":"Articles","previous_headings":"","what":"Row Masking","title":"Post-Processing","text":"Row masking process blanking repeat row values within data frame give appearance grouping variables. table packages, gt, handle . packages, like huxtable, options like merging cells, may simplistic approach. Furthermore, common approach clinical tables data validation done output dataframe. example, note “Race n (%)” duplicated row. can blank using `apply_row_masks() second feature apply_row_masks() ability apply row breaks different groups data, example, different layers table. row breaks inserted blank rows. Additionally, row breaks inserted ’ll additional variable ord_break added dataframe, value 1 table data rows 2 newly added break rows. Character variables blank values (.e. \"\") numeric sorting values NA. considerations using apply_row_masks(): function order dependent, make sure data sorted submitting apply_row_masks() inserting row breaks, default Tpylr variable ord_layer_index used. can submit variables via ellipsis parameter (...) ’d like use different variable grouping insert rows","code":"dat <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE, by = \"Race n (%)\") ) %>% build() %>% select(1:3) kable(dat) dat %>% apply_row_masks() %>% kable() dat <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE, by = \"Race n (%)\") ) %>% add_layer( group_desc(AGE, by = \"Age (years)\") ) %>% build() dat %>% apply_row_masks(row_breaks=TRUE) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"collapsing-row-labels","dir":"Articles","previous_headings":"","what":"Collapsing Row Labels","title":"Post-Processing","text":"Different table formats call different handling row labels, depending preferences individual organization specifics table hand. Tplyr inherently creates row labels separate columns, similar way count layers nest inner outer layer, also offer collapse_row_labels() function pull multiple row labels single column. default, indentation set 2 spaces, using indent parameter can change string desire. also control columns collapse, allowing keep separate row labels don’t want collapsed together","code":"dat <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE, by = vars(\"Race n (%)\", SEX)) ) %>% add_layer( group_desc(AGE, by = vars(\"Age (years)\", SEX)) ) %>% build() collapse_row_labels(dat, row_label1, row_label2, row_label3) %>% select(row_label, var1_Placebo) #> # A tibble: 26 × 2 #> row_label var1_Placebo #> #> 1 \"Race n (%)\" \"\" #> 2 \" F\" \"\" #> 3 \" AMERICAN INDIAN OR ALASKA NATIVE\" \" 0 ( 0.0%)\" #> 4 \" BLACK OR AFRICAN AMERICAN\" \" 5 ( 5.8%)\" #> 5 \" WHITE\" \"48 ( 55.8%)\" #> 6 \"Race n (%)\" \"\" #> 7 \" M\" \"\" #> 8 \" AMERICAN INDIAN OR ALASKA NATIVE\" \" 0 ( 0.0%)\" #> 9 \" BLACK OR AFRICAN AMERICAN\" \" 3 ( 3.5%)\" #> 10 \" WHITE\" \"30 ( 34.9%)\" #> # ℹ 16 more rows collapse_row_labels(dat, row_label1, row_label2, row_label3, indent = \"  \") %>% select(row_label, var1_Placebo) %>% kable(escape=FALSE) collapse_row_labels(dat, row_label1, row_label2, indent = \"  \") %>% select(row_label, row_label3, var1_Placebo) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"leading-spaces-in-html-files","dir":"Articles","previous_headings":"","what":"Leading Spaces in HTML Files","title":"Post-Processing","text":"Another helper function ’ve made available replace_leading_whitespace(). table created , note indent parameter set using  , non-breaking space. can used HTML files preserve leading white spaces instead automatically stripping display, viewing utilities usually . Ever noticed data viewers typically don’t see leading spaces? Yeah - ’s ! Let’s take example change indent parameter. indented rows, spaces still exist, can see dataframe output . HTML view strips pass kable() function. replace_leading_whitespace() take care us converting spaces. Note ’ll see   raw data . now want use display,   characters show leading whitespace within HTML table. Note ’ll need prevent escaping special characters work, raw text display. kable() can use escape=FALSE .","code":"collapse_row_labels(dat, row_label1, row_label2) %>% select(row_label, row_label3, var1_Placebo) %>% kable() collapse_row_labels(dat, row_label1, row_label2) %>% select(row_label, row_label3, var1_Placebo) %>% head() #> # A tibble: 6 × 3 #> row_label row_label3 var1_Placebo #> #> 1 \"Race n (%)\" \"\" \"\" #> 2 \" F\" \"AMERICAN INDIAN OR ALASKA NATIVE\" \" 0 ( 0.0%)\" #> 3 \" F\" \"BLACK OR AFRICAN AMERICAN\" \" 5 ( 5.8%)\" #> 4 \" F\" \"WHITE\" \"48 ( 55.8%)\" #> 5 \" M\" \"AMERICAN INDIAN OR ALASKA NATIVE\" \" 0 ( 0.0%)\" #> 6 \" M\" \"BLACK OR AFRICAN AMERICAN\" \" 3 ( 3.5%)\" collapse_row_labels(dat, row_label1, row_label2) %>% select(row_label, row_label3, var1_Placebo) %>% mutate( across(where(is.character), ~ replace_leading_whitespace(.)) ) %>% head() #> # A tibble: 6 × 3 #> row_label row_label3 var1_Placebo #> #> 1 Race n (%) \"\" \"\" #> 2   F \"AMERICAN INDIAN OR ALASKA NATIVE\" \" 0 ( 0.0%)\" #> 3   F \"BLACK OR AFRICAN AMERICAN\" \" 5 ( 5.8%)\" #> 4   F \"WHITE\" \"48 ( 55.8%)\" #> 5   M \"AMERICAN INDIAN OR ALASKA NATIVE\" \" 0 ( 0.0%)\" #> 6   M \"BLACK OR AFRICAN AMERICAN\" \" 3 ( 3.5%)\" collapse_row_labels(dat, row_label1, row_label2) %>% select(row_label, row_label3, var1_Placebo) %>% mutate( across(where(is.character), ~ replace_leading_whitespace(.)) ) %>% head() %>% kable(escape=FALSE)"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"conditional-formatting","dir":"Articles","previous_headings":"","what":"Conditional Formatting","title":"Post-Processing","text":"circumstances, like add_total_row(), Tplyr lets specify special formats separate set_format_strings(). within table body ’s way set specific, conditional formats based table data . address , ’ve added post-processing function apply_conditional_format() allow set conditional formats result cells. apply_conditional_format() operates character vector, can generally used within context dplyr::mutate() like character modifying function. make 1:1 replacement values, return character vector equal length. Let’s look two examples. two examples achieve result, work slightly differently. Let’s walk throug syntax: first parameter input character vector second parameter refers format group. format group index number within result cell ’d like target. result 8 (9.3%), two format groups. value first 8. value second 9.3. controls number ’ll use establish condition. third parameter condition evaluate establish conditional format applied. , use variable name x, takes value chosen format group. condition filter condition, must return boolean vector TRUE/FALSE. fourth parameter string value used replacement. Finally, last parameter full_string, difference first second examples. apply_conditional_format() can two types replacements. first example full string replacement. case, whatever value provide replacement used verbatim condition evaluates TRUE. set false, format group specified replaced. context, let’s look third example. example target percent field using format group 2, now replacement text (<1%). full_string uses default value FALSE, format group specified replaced. apply_conditional_format() establishes width format group targeted, replacement text right align within targetted portion string ensure alignment string preserved. example within Tplyr result dataframe, let’s look example dataset earlier. Let’s say n (%) values within first count layer conditional format. Using fancy dplyr code, apply_conditional_format(), can make happen. syntax gets bit complicated, using dplyr::across() can apply function across result variables, variable names start var. function using purrr style anonymous function simplicity. couple ways can R. Referencing documentation purrr::map(): formula, e.g. ~ . + 1. must use . refer first argument. recommended require backward compatibility older versions R. anonymous function, e.g. \\(x) x + 1 function(x) x + 1. Within function, ’re additionally using if_else() apply function first layer using ord_layer_index variable. together, ’re effectively running apply_conditional_formats() function first layer, running across variables start var.","code":"string <- c(\" 0 (0.0%)\", \" 8 (9.3%)\", \"78 (90.7%)\") apply_conditional_format(string, 2, x == 0, \" 0 \", full_string=TRUE) #> [1] \" 0 \" \" 8 (9.3%)\" \"78 (90.7%)\" apply_conditional_format(string, 2, x == 0, \"\") #> [1] \" 0 \" \" 8 (9.3%)\" \"78 (90.7%)\" apply_conditional_format(string, 2, x < 1, \"(<1%)\") #> [1] \" 0 (<1%)\" \" 8 (9.3%)\" \"78 (90.7%)\" dat_new <- dat %>% mutate( across(starts_with('var'), # Apply to variables that start with `var` ~ if_else( ord_layer_index == 1, # Target the count layer apply_conditional_format( string = ., # This is dplyr::across syntax format_group = 2, # The percent field condition = x == 0, # Our condition replacement = \"\" # Replacement value ), . ) ) ) kable(dat_new)"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"extracting-a-format-group","dir":"Articles","previous_headings":"","what":"Extracting a Format Group","title":"Post-Processing","text":"Tplyr outputs result, using set_format_strings() f_str() result concatenated together within single result cell. example, within count layer Tplyr table, ’s way directly output n pct values separate columns. result want, post-processing step can use function str_extract_fmt_group(). str_extract_fmt_group() allows reach within result string extract individual format group. Consider example: first call str_extract_fmt_group(), target n counts. first format group string extracted, preserving allotted width portion string. Similarly, second group extract percent counts, including surround parentheses. practice, str_extract_fmt_group() can used separate format groups columns. sake display, output select Placebo column, note able dynamically separate n results pct results. cases, functions tidyr::separate() also used get result like , str_extract_fmt_group() specifically targets expected formatting format groups, without craft specific expression may get confused things like spaces unexpected places.","code":"string <- c(\" 5 (5.8%)\", \" 8 (9.3%)\", \"78 (90.7%)\") # Get the n counts str_extract_fmt_group(string, 1) #> [1] \" 5\" \" 8\" \"78\" # Get the pct counts str_extract_fmt_group(string, 2) #> [1] \"(5.8%)\" \"(9.3%)\" \"(90.7%)\" dat <- tplyr_table(tplyr_adsl, TRT01P) %>% add_layer( group_count(RACE) ) %>% build() dat %>% mutate( across(starts_with('var'), ~ str_extract_fmt_group(., 1), .names = \"{.col}_n\"), across(starts_with('var'), ~ str_extract_fmt_group(., 2), .names = \"{.col}_pct\") ) %>% select(row_label1, var1_Placebo_n, var1_Placebo_pct) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"highly-customized-sort-variables","dir":"Articles","previous_headings":"","what":"Highly Customized Sort Variables","title":"Post-Processing","text":"much vein str_extract_fmt_group(), function str_extract_num() allows target format group extract number within. can used circumstance may want pull number result cell, probably best example highly specific sort sequence. Consider adverse event table. vignette(\"sort\") go circumstances may want sort descending occurrence result. ’ve received questions establish tie breakers scenario, ties broken sorting descending occurrence adverse event within high dose group, low dose group, finally placebo group. Tplyr doesn’t allow output order variables default, getting numbers quite simple str_extract_num(). Let’s consider simplified scenario Given data, let’s say want sort descending occurrence event, using number subjects. first format group. want sort using high dose, low dose, placebo. Let’s create order variables. Now effectively additional order variables necessary sort sequence desired.","code":"dat <- tplyr_table(tplyr_adae, TRTA) %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% add_layer( group_count(AEDECOD) %>% set_format_strings(f_str(\"xx (XX.x%) [A]\", distinct_n, distinct_pct, n)) %>% set_distinct_by(USUBJID) ) %>% build() dat %>% head() %>% kable() dat_ord <- dat %>% mutate( across(starts_with('var1'), ~str_extract_num(., 1), .names = \"{.col}_ord\") ) dat_ord %>% head() %>% select(row_label1, matches('^var.*ord$')) #> # A tibble: 6 × 4 #> row_label1 var1_Placebo_ord var1_Xanomeline High…¹ var1_Xanomeline Low …² #> #> 1 ACTINIC KERATO… 0 1 0 #> 2 ALOPECIA 1 0 0 #> 3 BLISTER 0 1 5 #> 4 COLD SWEAT 1 0 0 #> 5 DERMATITIS ATO… 1 0 0 #> 6 DERMATITIS CON… 0 0 1 #> # ℹ abbreviated names: ¹​`var1_Xanomeline High Dose_ord`, #> # ²​`var1_Xanomeline Low Dose_ord`"},{"path":"https://atorus-research.github.io/Tplyr/articles/post_processing.html","id":"external-data-formatting","dir":"Articles","previous_headings":"","what":"External Data Formatting","title":"Post-Processing","text":"last post processing function worth mentioning isn’t necessarily meant post-processing data Tplyr . understand Tplyr can’t produce every single summary ’d need clinical trial - never intended able . built Tplyr try work effectively packages tools. Tplyr’s string formatting tools work quite well, ’ve externalized capability using function apply_formats(). basic example, let’s look mtcars data. able leverage string formatting available f_str(), apply generically another data frame within dplyr::mutate(). allows format data, outside Tplyr, still bring quality life Tplyr offer.","code":"mtcars %>% mutate( new_column = apply_formats(\"xx (xx.x)\", gear, mpg) ) %>% select(gear, mpg, new_column) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/riskdiff.html","id":"tplyr-implementation","dir":"Articles","previous_headings":"","what":"Tplyr Implementation","title":"Risk Difference","text":"current implementation risk difference solely built top base R function stats::prop.test(). questions method, please review stats::prop.test() documentation within R. Risk difference built top count layers, ’s comparison proportions. add risk difference calculation count layer, simply use function add_risk_diff(). made large effort make flow naturally count layer construction, let’s walk step step. Comparisons specified two-element character vectors. simply comparison group - first element, reference group - second. coincides might see risk difference specified header mock, ’ll see something like T1-Placebo. can provide many comparisons want - values specified comparison just need valid treatment groups within data. works treatment group built using add_treat_grps() add_total_group() well. risk difference calculations displayed rdiff columns. rdiff column every comparison made, following convention rdiff__. Note use base::suppressWarnings() - counts used stats::prop.test() low, ’ll get warning says “Chi-squared approximation may incorrect” every time stats::prop.test() run counts low… happen lot, warning perfectly valid.","code":"t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo') ) ) suppressWarnings(build(t)) %>% head() %>% select(starts_with(\"rdiff\"), everything()) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/riskdiff.html","id":"controlling-presentation","dir":"Articles","previous_headings":"","what":"Controlling Presentation","title":"Risk Difference","text":"default values presented within formatted strings built table : difference 95% confidence interval low 95% confidence interval high good bit control values though, can controlled way format count summaries - using set_format_strings(). Take look rdiff columns now - ’ll see 5 values. : comparison proportion (.e. estimate[1] output stats::prop.test() object) reference proportion (.e. estimate[2] output stats::prop.test() object) difference (.e. estimate[1] - estimate[2]) lower end confidence interval upper end confidence interval control formatting display values count summaries. Taking things step , can also pass forward arguments stats::prop.test() using named list args argument add_risk_diff(). wasn’t done using ellipsis (.e. ...) like typical R functions ’s already used capture varying number comparisons, ’s much difficult use: seen , using args argument, : Changed confidence interval level 90% instead default 95% Switched alternative hypothesis stats::prop.test() “less” instead default “two.sided” Turned Yates’ continuity correction information parameters, see documentation stats::prop.test().","code":"t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo') ) %>% set_format_strings( 'n_counts' = f_str('xx (xx.x) [x]', distinct_n, distinct_pct, n), 'riskdiff' = f_str('xx.xxx, xx.xxx, xx.xxx, xx.xxx, xx.xxx', comp, ref, dif, low, high) ) ) suppressWarnings(build(t)) %>% head() %>% select(starts_with(\"rdiff\"), everything()) %>% kable() t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo'), args = list(conf.level=0.90, alternative='less', correct=FALSE) ) %>% set_format_strings( 'n_counts' = f_str('xx (xx.x) [x]', distinct_n, distinct_pct, n), 'riskdiff' = f_str('xx.xxx, xx.xxx, xx.xxx, xx.xxx, xx.xxx', comp, ref, dif, low, high) ) ) suppressWarnings(build(t)) %>% head() %>% select(starts_with(\"rdiff\"), everything()) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/riskdiff.html","id":"other-notes","dir":"Articles","previous_headings":"","what":"Other Notes","title":"Risk Difference","text":"default add_risk_diff() works distinct counts available within count summary. whatever reason ’d like run risk difference non-distinct counts, switch distinct argument FALSE. add_risk_diff() also function multi-level summaries different single level, concerns either. Risk difference also works cols argument, ’s important understand comparisons work situation. , ’s still treatment groups compared - column argument used “” variable. example:","code":"t <- tplyr_table(tplyr_adae, TRTA, where= AEBODSYS == \"SKIN AND SUBCUTANEOUS TISSUE DISORDERS\") %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% set_pop_where(TRUE) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo') ) ) suppressWarnings(build(t)) %>% head() %>% select(starts_with(\"rdiff\"), everything()) %>% kable() t <- tplyr_table(tplyr_adae, TRTA, where= AEBODSYS == \"SKIN AND SUBCUTANEOUS TISSUE DISORDERS\") %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo'), distinct=FALSE ) ) suppressWarnings(build(t)) %>% head() %>% select(starts_with(\"rdiff\"), everything()) %>% kable() t <- tplyr_table(tplyr_adae, TRTA, where= AEBODSYS == \"SKIN AND SUBCUTANEOUS TISSUE DISORDERS\", cols=SEX) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo') ) ) suppressWarnings(build(t)) %>% head() %>% select(starts_with(\"rdiff\"), starts_with(\"row\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/riskdiff.html","id":"getting-raw-numbers","dir":"Articles","previous_headings":"","what":"Getting Raw Numbers","title":"Risk Difference","text":"Just like can get numeric data Tplyr layer get_numeric_data(), ’ve also opened door extract raw numeric data risk difference calculations well. done using function get_stats_data(). function interface almost identical get_numeric_data(), except extra parameter statistic. Although risk difference statistic implemented Tplyr moment (outside descriptive statistics), understand multiple methods calculate risk difference, ’ve built risk difference way expanded easily add new methods future. therefore, get_stats_data() statistic parameter allow differentiate situation multiple statistical methods applied layer. output get_stats_data() depends parameters used: specific layer entered layer parameter, element returned layer statistic entered statistic parameter, element returned statistic layer neither statistic layer entered, list lists returned, outer list layer inside list numeric statistic data layer. works best layers named, makes output much clearer. Instead playing around lists, get_stats_data() advantageous ’d like extract data specifically. Let’s say ’d like see just difference values Preferred Term layer table . Using data frame, access un-formatted numeric values rounding formatting. gives flexibility use calculations contexts, make precise comparisons double programming scenario, take deeper look calculations made values result warrant investigation.","code":"t <- tplyr_table(tplyr_adae, TRTA) %>% add_layer(name=\"PreferredTerm\", group_count(AEDECOD) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo') ) ) %>% add_layer(name=\"BodySystem\", group_count(AEBODSYS) %>% set_distinct_by(USUBJID) %>% add_risk_diff( c('Xanomeline High Dose', 'Placebo'), c('Xanomeline Low Dose', 'Placebo') ) ) suppressWarnings( get_stats_data(t) ) #> $PreferredTerm #> $PreferredTerm$riskdiff #> # A tibble: 105 × 4 #> summary_var measure Xanomeline High Dose_Place…¹ Xanomeline Low Dose_…² #> #> 1 ACTINIC KERATOSIS comp 0.0238 0 #> 2 ACTINIC KERATOSIS ref 0 0 #> 3 ACTINIC KERATOSIS dif 0.0238 0 #> 4 ACTINIC KERATOSIS low -0.0461 0 #> 5 ACTINIC KERATOSIS high 0.0937 0 #> 6 ALOPECIA comp 0 0 #> 7 ALOPECIA ref 0.0476 0.0476 #> 8 ALOPECIA dif -0.0476 -0.0476 #> 9 ALOPECIA low -0.174 -0.174 #> 10 ALOPECIA high 0.0792 0.0792 #> # ℹ 95 more rows #> # ℹ abbreviated names: ¹​`Xanomeline High Dose_Placebo`, #> # ²​`Xanomeline Low Dose_Placebo` #> #> #> $BodySystem #> $BodySystem$riskdiff #> # A tibble: 5 × 4 #> summary_var measure Xanomeline High Dose…¹ Xanomeline Low Dose_…² #> #> 1 SKIN AND SUBCUTANEOUS T… comp 1 1 #> 2 SKIN AND SUBCUTANEOUS T… ref 1 1 #> 3 SKIN AND SUBCUTANEOUS T… dif 0 0 #> 4 SKIN AND SUBCUTANEOUS T… low 0 0 #> 5 SKIN AND SUBCUTANEOUS T… high 0 0 #> # ℹ abbreviated names: ¹​`Xanomeline High Dose_Placebo`, #> # ²​`Xanomeline Low Dose_Placebo` suppressWarnings( get_stats_data(t, layer='PreferredTerm', statistic='riskdiff', where= measure == \"dif\") ) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/shift.html","id":"a-basic-example","dir":"Articles","previous_headings":"","what":"A Basic Example","title":"Shift Layers","text":"Let’s look example. First, let’s look differences shift API. Shift layers must take row column variable, layer designed create box explains changes state. row variable typically “” variable, column variable typically “” variable. Behind scenes, Tplyr breaks properly count present data. part, last example gets us want go - ’s still ’s left desired. doesn’t look like ‘L’ values BNRIND dataset getting rows containing ‘L’. Let’s see can fix dummying possible values.","code":"tplyr_table(tplyr_adlb, TRTA, where=PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, VISIT)) ) %>% build() %>% head(20) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/shift.html","id":"filling-missing-groups-using-factors","dir":"Articles","previous_headings":"","what":"Filling Missing Groups Using Factors","title":"Shift Layers","text":"go. another situation using factors R let’s us dummy values within dataset. Furthermore, since factors ordered, automatically corrected sort order row labels .","code":"tplyr_adlb$ANRIND <- factor(tplyr_adlb$ANRIND, levels=c(\"L\", \"N\", \"H\")) tplyr_adlb$BNRIND <- factor(tplyr_adlb$BNRIND, levels=c(\"L\", \"N\", \"H\")) tplyr_table(tplyr_adlb, TRTA, where=PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, VISIT)) ) %>% build() %>% head(20) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/shift.html","id":"where-to-go-from-here","dir":"Articles","previous_headings":"","what":"Where to go from here","title":"Shift Layers","text":"’s much learn! Check sorting vignette information sorting. Additionally, check vignette denominators understand controlling nuance shift tables.","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"ordering-helpers","dir":"Articles","previous_headings":"Sorting Table Columns","what":"Ordering Helpers","title":"Sorting a Tplyr Table","text":"Ordering helpers columns added Tplyr tables make sure can sort display preference. general, Tplyr create: One order variable order layers One order variable variable least one order variable target variables example , t table outputs three columns: ord_layer_index indexes layer . ord_layer_1 indexes first variable, SEX. options presented sorting done alphabetically. ord_layer_2 indexes values EOSSTT variable count layer, names summaries desc layer.","code":"t %>% select(starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"reordering-and-dropping-columns","dir":"Articles","previous_headings":"Sorting Table Columns","what":"Reordering and Dropping Columns","title":"Sorting a Tplyr Table","text":"Column selection data frames something already well done R. functions dplyr::select(), magrittr::extract(), [ can used reorder drop column cleanly concisely based user’s preference. drop ordering helpers, can easily subtract ‘dplyr’ ‘tidyselect’. can reorder columns. example “Total” result column moved front results. information, ’s well worth time familiarize select helpers work ‘dplyr’.","code":"t %>% select(-starts_with(\"ord_\")) %>% kable() t %>% select( starts_with(\"row\"), var1_Total, starts_with(\"var1\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"sorting-the-layers","dir":"Articles","previous_headings":"","what":"Sorting the Layers","title":"Sorting a Tplyr Table","text":"Layers one fundamental building blocks Tplyr. layer executes independently, end build ’re bound together. ord_layer_index variable allows differentiate sort layers table built. Layers indexed order added table using add_layer() add_layers(). example, let’s say wanted reverse order layers.","code":"t %>% select(starts_with(\"row\"), starts_with(\"ord\")) %>% arrange(desc(ord_layer_index)) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"sorting-the-by-variables","dir":"Articles","previous_headings":"","what":"Sorting the by Variables","title":"Sorting a Tplyr Table","text":"variable gets order column well. named ord_layer_ typically relates back row_label variable (isn’t necessarily case count layers nested - see vignette(\"count\")). order variables calculate based first applicable method . variable factor, values ordering column associated factor levels. variable VARN variable target dataset, (.e. AVISIT AVISITN, PARAM PARAMN), variable extracted used ordering variable associated row label. neither 1 2 true, values ordering column based alphabetical sorting. resulting column numeric.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"factor","dir":"Articles","previous_headings":"Sorting the by Variables","what":"Factor","title":"Sorting a Tplyr Table","text":"’s VARN variable target dataset, Tplyr check variable provided factor. ’re new R, spending time trying understand factor variables quite worthwhile. Let’s look example using variable ETHNIC see advantages practice. Factor variables ‘levels’. levels essentially VARN variables trying achieve - specify order different values within associated variable. variable set specifies “HISPANIC LATINO” sort first, “HISPANIC LATINO”, finally “DUMMY”. Notice ’re alphabetical? highly advantageous aspect using factor variables Tplyr factor variables can used insert dummy values table. Consider line code : converting variable ETHNIC factor, setting factor levels. doesn’t change values dataset - values “dummy” within ETHNIC ADSL. Yet output built , see rows “DUMMY”. using factors, can insert rows Tplyr table don’t exist data. particularly helpful ’re working data early study, certain values expected, yet currently exist data. help prepare tables complete even data .","code":"tplyr_adsl$ETHNIC <- factor(tplyr_adsl$ETHNIC, levels=c(\"HISPANIC OR LATINO\", \"NOT HISPANIC OR LATINO\", \"DUMMMY\")) tplyr_table(tplyr_adsl, TRT01A) %>% add_layer( group_count(EOSSTT, by = ETHNIC) ) %>% build() %>% select(row_label1, row_label2, ord_layer_1) %>% kable() tplyr_adsl$ETHNIC <- factor(tplyr_adsl$ETHNIC, levels=c(\"HISPANIC OR LATINO\", \"NOT HISPANIC OR LATINO\", \"DUMMMY\"))"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"varn","dir":"Articles","previous_headings":"Sorting the by Variables","what":"VARN","title":"Sorting a Tplyr Table","text":"demonstrate use VARN sorting, consider variable RACE. ADSL, RACE also RACEN: Tplyr automatically figure , pull RACEN values variable ord_layer_1.","code":"tplyr_adsl %>% distinct(RACEN, RACE) %>% kable() tplyr_table(tplyr_adsl, TRT01A) %>% add_layer( group_count(EOSSTT, by = RACE) ) %>% build() %>% select(row_label1, row_label2, ord_layer_1) %>% arrange(ord_layer_1) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"alphabetical","dir":"Articles","previous_headings":"Sorting the by Variables","what":"Alphabetical","title":"Sorting a Tplyr Table","text":"Lastly, target doesn’t VARN variable target dataset isn’t factor,Tplyr sort variable alphabetically. resulting order variable numeric, simply numbering variable values alphabetically. Nothing fancy !","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"sorting-descriptive-statistic-summaries","dir":"Articles","previous_headings":"","what":"Sorting Descriptive Statistic Summaries","title":"Sorting a Tplyr Table","text":"variables, layer sort results slightly differently. ’ll start simple case - descriptive statistic layers. user, full control order results present using set_format_strings(). Results ordered based order create f_str() objects. separate “Groups” added indexed based position set_format_strings(). ’d like change order, need update set_format_strings() call.","code":"tplyr_table(tplyr_adsl, TRT01A) %>% add_layer( group_desc(HEIGHTBL) %>% set_format_strings( 'Group 1' = f_str('xx.x', mean), 'Group 2' = f_str('xx.x', median), 'Group 3' = f_str('xx.x', sd) ) ) %>% build() %>% select(starts_with(\"row\"), starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"sorting-count-layers","dir":"Articles","previous_headings":"","what":"Sorting Count Layers","title":"Sorting a Tplyr Table","text":"order results appear frequency table can deceptively complex depends situation hand. mind, Tplyr 3 different methods ordering results count layer using function set_order_count_method(): “byfactor” - default method sort factor. input variable factor, alphabetical sorting used. “byvarn” - Similar ‘’ variable, count target can sorted VARN variable existing target dataset. “bycount” - complex method. Many tables require counts sorted based counts within particular group, like treatment variable. Tplyr can populate ordering column based numeric values within results column. requires granular control, ’ve created functions set_ordering_cols() set_result_order_var() specify column numeric value ordering column based.","code":""},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"byfactor-and-byvarn","dir":"Articles","previous_headings":"Sorting Count Layers","what":"“byfactor” and “byvarn”","title":"Sorting a Tplyr Table","text":"“byfactor” default ordering method results count layers. “byfactor” “byvarn” behave exactly like order variables associated variables Tplyr table. “byvarn”, must set sort method using set_order_count_method().","code":"tplyr_adsl$AGEGR1 <- factor(tplyr_adsl$AGEGR1, c(\"<65\", \"65-80\", \">80\")) # Warnings suppressed to remove 'forcats' implicit NA warning suppressWarnings({ tplyr_table(tplyr_adsl, TRT01A) %>% add_layer( group_count(AGEGR1) %>% # This is the default and not needed set_order_count_method(\"byfactor\") ) %>% build() %>% select(row_label1, ord_layer_1) %>% kable() }) tplyr_table(tplyr_adsl, TRT01A) %>% add_layer( group_count(RACE) %>% set_order_count_method(\"byvarn\") ) %>% build() %>% select(row_label1, ord_layer_1) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"bycount","dir":"Articles","previous_headings":"Sorting Count Layers","what":"“bycount”","title":"Sorting a Tplyr Table","text":"Using count-based sorting things get complicated. multiple items consider: column want sort ? multiple numbers column, like “n (%) [event]” type tables, number used create sort variable? ’ve created helper functions aid making step intuitive user perspective, maintain flexibility need. two functions need set_ordering_cols() set_result_order_var(). example, results columns output table actually contain three different numbers: distinct counts, distinct percentage, non-distinct counts. want use distinct counts, choose distinct_n. next question need answer sorting counts result column take counts . , three results columns - one treatment group dataset. want use results treatment group “Xanomeline High Dose”, provide name treatment group. additional column variable top treatment groups? ’re ordering female subjects “Xanomeline High Dose” cohort. set_result_order_var(), need enter values variable treat_var variable entered cols ’d like extract.","code":"tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(AEDECOD) %>% # This will present 3 numbers in a cell set_format_strings(f_str(\"xx (xx.x%) [x]\", distinct_n, distinct_pct, n)) %>% # This makes the distinct numbers available set_distinct_by(USUBJID) %>% # Choosing \"bycount\" ordering for the result variable set_order_count_method(\"bycount\") %>% # This will target the results column for Xanomeline High Dose, or `var1_Xanomeline High Dose` set_ordering_cols(\"Xanomeline High Dose\") %>% # The number we want to pull out is the distinct N counts set_result_order_var(distinct_n) ) %>% build() %>% arrange(desc(ord_layer_1)) %>% select(row_label1, `var1_Xanomeline High Dose`, ord_layer_1) %>% head() %>% kable() tplyr_table(tplyr_adae, TRTA, cols=SEX) %>% add_layer( group_count(AEDECOD) %>% # This will present 3 numbers in a cell set_format_strings(f_str(\"xx (xx.x%) [x]\", distinct_n, distinct_pct, n)) %>% # This makes the distinct numbers available set_distinct_by(USUBJID) %>% # Choosing \"bycount\" ordering for the result variable set_order_count_method(\"bycount\") %>% # This will target the results column for Xanomeline High Dose, or `var1_Xanomeline High Dose` set_ordering_cols(\"Xanomeline High Dose\", \"F\") %>% # The number we want to pull out is the distinct N counts set_result_order_var(distinct_n) ) %>% build() %>% arrange(desc(ord_layer_1)) %>% select(row_label1, `var1_Xanomeline High Dose_F`, ord_layer_1) %>% head() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"nested-sorting","dir":"Articles","previous_headings":"","what":"Nested Sorting","title":"Sorting a Tplyr Table","text":"Nested count layers add one piece puzzle. reminder, nested count layers count summaries summarizing grouping variable, variable ’s grouped. best example probably Adverse Event tables, want see adverse events occurred within different body systems. layer uses nesting, need one order variable - ’re now concerned sorting outside inside variable. Counts summarized - need know sorted. Additionally, need make sure , case, adverse events within body system stay within rows body system. result variables always last two order variables output Tplyr. example, ord_layer_1 AEBODSYS ord_layer_2 AEDECOD. Note ord_layer_2 Inf row_label1 row_label2 equal. row summarizes AEBODSYS counts. default, Tplyr set assume use descending sort order variable associated inside count variable (.e. AEDECOD). nested count layer often want sort descending occurrence inside target variable. ’d like use ascending sorting instead, offer function set_outer_sort_position(). Notice Inf now switched -Inf ensure AEBODSYS row stays top group. Another consideration nested sorting whether want sort result variables way. want sort counts? want sort one alphabetically count? maybe one VARN variable associated ? reason, set_order_count_method() can take 2-element character vector, first element specifies outside variable second inside variable. example , EOSTT ordered alphabetically (recall using “byfactor” variable factor alphabetical sorting), DSDECOD ordered count. one method provided, method automatically applied variables. example , “bycount” applied EOSTT DSDECOD.","code":"tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) ) %>% build() %>% head() %>% kable() tplyr_table(tplyr_adae, TRTA) %>% add_layer( group_count(vars(AEBODSYS, AEDECOD)) %>% set_outer_sort_position(\"asc\") ) %>% build() %>% arrange(ord_layer_1, ord_layer_2) %>% select(starts_with(\"row\"), starts_with(\"ord_layer\")) %>% head() %>% kable() tplyr_table(tplyr_adsl, TRT01A) %>% add_layer( group_count(vars(EOSSTT, DCDECOD)) %>% set_order_count_method(c(\"byfactor\", \"bycount\")) ) %>% build() %>% select(starts_with(\"row\"), starts_with(\"ord\")) %>% kable() tplyr_table(tplyr_adsl, TRT01A) %>% add_total_group() %>% add_layer( group_count(vars(EOSSTT, DCDECOD)) %>% set_order_count_method(\"bycount\") %>% #set_order_count_method(\"bycount\", \"bycount\") %>% This is functionally the same. set_ordering_cols(Total) ) %>% build() %>% select(starts_with(\"row\"), var1_Total, starts_with(\"ord\")) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/sort.html","id":"sorting-shift-tables","dir":"Articles","previous_headings":"","what":"Sorting Shift Tables","title":"Sorting a Tplyr Table","text":"Shift tables keep things relatively simple comes sorting use “byfactor” method seen . encourage primarily likely want benefits factor variables shift layer. example, consider table: problems : “H” sorts “N” alphabetically ’re missing rows “L” visits, even though “L” data BNRIND. Using factor variables cleans right us: Now nice “L”, “N”, “H” order ’d like see. sort methods shift table fairly unlikely, matrix structure counts displayed shift tables relevant presentation interpreting results. Happy sorting!","code":"tplyr_table(tplyr_adlb, TRTA, where=PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, AVISIT)) ) %>% build() %>% select(-starts_with('var1')) %>% head(20) %>% kable() tplyr_adlb$BNRIND <- factor(tplyr_adlb$BNRIND, levels=c(\"L\", \"N\", \"H\")) tplyr_adlb$ANRIND <- factor(tplyr_adlb$ANRIND, levels=c(\"L\", \"N\", \"H\")) tplyr_table(tplyr_adlb, TRTA, where=PARAMCD == \"CK\") %>% add_layer( group_shift(vars(row = BNRIND, column = ANRIND), by = vars(PARAM, AVISIT)) ) %>% build() %>% select(-starts_with('var1')) %>% head(20) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/styled-table.html","id":"preparing-the-data","dir":"Articles","previous_headings":"","what":"Preparing the data","title":"Producing a Styled Table","text":"block , assembled count descriptive statistic summaries one one. notice pre-processing dataset. important considerations : Tplyr data cleaning. summarize prepare data enter. ’re following CDISC standards properly, shouldn’t concern - ADaM data already formatted presentation ready. Tplyr works assumption, won’t re-coding casing changes. example, original SEX values “M” “F” - switched “Male” “Female” instead. second pre-processing step something interesting. recall vignette(\"sort\"), factor variables input Tplyr use factor order resulting order variable. Another particularly useful advantage dummying values. adsl dataset contains races “WHITE”, “BLACK AFRICAN AMERICAN”, “AMERICAN INDIAN ALASK NATIVE”. set factor levels prior entering data Tplyr, values dummied . particularly advantageous study early data may sparse. output can display complete values presentation consistent data come . Data may sometimes need additional post-processing well. example, sometimes statisticians may want special formatting things like show percent count 0. function apply_conditional_formatting() can used post process character strings based numbers present within string. example, targetted count layers layer index (ord_layer_index) used dplyr::across() target result columns. Within apply_conditional_format() saying take string, look second number, ’s equal 0 replace entire string segment blank. information apply_conditional_format() function, see function documentation. now, ’ll leave data frame unedited rest example.","code":"tplyr_adsl <- tplyr_adsl %>% mutate( SEX = recode(SEX, M = \"Male\", F = \"Female\"), RACE = factor(RACE, c(\"AMERICAN INDIAN OR ALASKA NATIVE\", \"ASIAN\", \"BLACK OR AFRICAN AMERICAN\", \"NATIVE HAWAIIN OR OTHER PACIFIC ISLANDER\", \"WHITE\", \"MULTIPLE\")) ) t <- tplyr_table(tplyr_adsl, TRT01P) %>% add_total_group() %>% add_layer(name = 'Sex', group_count(SEX, by = \"Sex n (%)\") %>% set_missing_count(f_str('xx', n), Missing=NA, denom_ignore=TRUE) ) %>% add_layer(name = 'Age', group_desc(AGE, by = \"Age (Years)\") ) %>% add_layer(name = 'Age group', group_count(AGEGR1, by = \"Age Categories n (%)\") %>% set_missing_count(f_str('xx', n), Missing=NA, denom_ignore=TRUE) ) %>% add_layer(name = 'Race', group_count(RACE, by = \"Race n (%)\") %>% set_missing_count(f_str('xx', n), Missing=NA, denom_ignore=TRUE) %>% set_order_count_method(\"byfactor\") ) %>% add_layer(name = 'Ethnic', group_count(ETHNIC, by = \"Ethnicity n (%)\") %>% set_missing_count(f_str('xx', n), Missing=NA, denom_ignore=TRUE) ) dat <- build(t) dat %>% kable() dat %>% mutate( across(starts_with('var'), ~ if_else( ord_layer_index %in% c(1, 3:5), apply_conditional_format( string = ., format_group = 2, condition = x == 0, replacement = \"\" ), . ) ) ) #> # A tibble: 23 × 9 #> row_label1 row_label2 var1_Placebo var1_Total var1_Xanomeline High…¹ #> #> 1 Sex n (%) Female \" 53 ( 61.6… \"143 ( 56… \" 40 ( 47.6%)\" #> 2 Sex n (%) Male \" 33 ( 38.4… \"111 ( 43… \" 44 ( 52.4%)\" #> 3 Sex n (%) Missing \" 0\" \" 0\" \" 0\" #> 4 Age (Years) n \" 86\" \"254\" \" 84\" #> 5 Age (Years) Mean (SD) \"75.2 ( 8.5… \"75.1 ( 8… \"74.4 ( 7.89)\" #> 6 Age (Years) Median \"76.0\" \"77.0\" \"76.0\" #> 7 Age (Years) Q1, Q3 \"69.2, 81.8\" \"70.0, 81… \"70.8, 80.0\" #> 8 Age (Years) Min, Max \"52, 89\" \"51, 89\" \"56, 88\" #> 9 Age (Years) Missing \" 0\" \" 0\" \" 0\" #> 10 Age Categories n (… <65 \" 14 ( 16.3… \" 33 ( 13… \" 11 ( 13.1%)\" #> # ℹ 13 more rows #> # ℹ abbreviated name: ¹​`var1_Xanomeline High Dose` #> # ℹ 4 more variables: `var1_Xanomeline Low Dose` , ord_layer_index , #> # ord_layer_1 , ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/articles/styled-table.html","id":"sorting-column-ordering-column-headers-and-clean-up","dir":"Articles","previous_headings":"","what":"Sorting, Column Ordering, Column Headers, and Clean-up","title":"Producing a Styled Table","text":"Now data, let’s make sure ’s right order. Additionally, let’s clean data ’s ready present. Now can see things coming together. block, : Sorted data layer, row labels (case just text strings defined), results. Review vignette(\"sort\") understand layer handles sorting detail. Used apply_row_masks() function. Essentially, data sorted, function look row_label variables drop repeating values. packages like huxtable, eases process making table presentation ready, don’t need cell merging huxtable table created. Additionally, set row_breaks option TRUE. insert blank row layers, helps improve presentation depending output. ’s important note input dataset must still ord_layer_index variable attached order blank rows added. Sorting done prior, column reordering/dropping may done . Re-ordered columns dropped order columns. information get dplyr::select(), can look ‘tidyselect’ . tidyselect::starts_with() comes . Added column headers. huxtable, column headers basically just top rows data frame. Tplyr function add_column_headers() letting just enter string define headers. ’s - can also create nested headers nesting text within curly brackets ({}), notice treatment groups within two stars? actually allows take header N values Tplyr calculates , use within column headers. can see first row output, text shows (N=XX) values populated proper header_n counts.","code":"dat <- dat %>% arrange(ord_layer_index, ord_layer_1, ord_layer_2) %>% apply_row_masks(row_breaks = TRUE) %>% select(starts_with(\"row_label\"), var1_Placebo, `var1_Xanomeline Low Dose`, `var1_Xanomeline High Dose`, var1_Total) %>% add_column_headers( paste0(\" | | Placebo\\\\line(N=**Placebo**)| Xanomeline Low Dose\\\\line(N=**Xanomeline Low Dose**) \", \"| Xanomeline High Dose\\\\line(N=**Xanomeline High Dose**) | Total\\\\line(N=**Total**)\"), header_n = header_n(t)) dat %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/styled-table.html","id":"table-styling","dir":"Articles","previous_headings":"","what":"Table Styling","title":"Producing a Styled Table","text":"lot options go next. gt package always good choice, ’ve using kableExtra throughout vignettes. moment, tools ’ve made available Tplyr, ’re aiming create RTF outputs (still common requirement within pharma companies), huxtable package pharmaRTF get need go. (Note: plan extend pharmaRTF support GT better RTF support) Alright - table ready. Let’s prepare huxtable table.","code":"# Make the table ht <- huxtable::as_hux(dat, add_colnames=FALSE) %>% huxtable::set_bold(1, 1:ncol(dat), TRUE) %>% # bold the first row huxtable::set_align(1, 1:ncol(dat), 'center') %>% # Center align the first row huxtable::set_align(2:nrow(dat), 3:ncol(dat), 'center') %>% # Center align the results huxtable::set_valign(1, 1:ncol(dat), 'bottom') %>% # Bottom align the first row huxtable::set_bottom_border(1, 1:ncol(dat), 1) %>% # Put a border under the first row huxtable::set_width(1.5) %>% # Set the table width huxtable::set_escape_contents(FALSE) %>% # Don't escape RTF syntax huxtable::set_col_width(c(.2, .2, .15, .15, .15, .15)) # Set the column widths ht"},{"path":"https://atorus-research.github.io/Tplyr/articles/styled-table.html","id":"output-to-file","dir":"Articles","previous_headings":"","what":"Output to File","title":"Producing a Styled Table","text":"now starting look lot like ’re going ! table styling coming together. last step get final output document. ’ll jump pharmaRTF may look little messy, pharmaRTF syntax can abbreviated standardizing process. Check vignette instructions read titles footnotes ‘pharmaRTF’ file. document now created, titles footnotes added, settings good go. Last step write . - table styled ready go! ’d like learn use huxtable, sure check website. use specifically pharmaRTF, prepared vignette tips tricks .","code":"doc <- pharmaRTF::rtf_doc(ht) %>% pharmaRTF::add_titles( pharmaRTF::hf_line(\"Protocol: CDISCPILOT01\", \"PAGE_FORMAT: Page %s of %s\", align='split', bold=TRUE, italic=TRUE), pharmaRTF::hf_line(\"Table 14-2.01\", align='center', bold=TRUE, italic=TRUE), pharmaRTF::hf_line(\"Summary of Demographic and Baseline Characteristics\", align='center', bold=TRUE, italic=TRUE) ) %>% pharmaRTF::add_footnotes( pharmaRTF::hf_line(\"FILE_PATH: Source: %s\", \"DATE_FORMAT: %H:%M %A, %B %d, %Y\", align='split', bold=FALSE, italic=TRUE) ) %>% pharmaRTF::set_font_size(10) %>% pharmaRTF::set_ignore_cell_padding(TRUE) %>% pharmaRTF::set_column_header_buffer(top=1) pharmaRTF::write_rtf(doc, file='styled_example.rtf')"},{"path":"https://atorus-research.github.io/Tplyr/articles/table.html","id":"table-parameters","dir":"Articles","previous_headings":"","what":"Table Parameters","title":"Tplyr Table Properties","text":"tplyr_table() function 4 parameters: target: dataset upon summaries performed treat_var: variable containing treatment group assignments : overarching table subset criteria. layer use subset default. parameter table level called addition layer subset criteria. cols: Grouping variables used addition variables set layer level, transposed columns addition treat_var. Let’s look example: example , parameter passed forward RACE AGE layers. Furthermore, note cols parameter works. default, target variables layers transposed treat_var variables. cols argument adds additional variable transpose , values variable added suffix variable name. able use multiple cols variables just like , using dplyr::vars(). use caution - depending distinct variable values dataset, get quite wide. Note: Treatment groups additional column variables presented final output always taken pre-filtered population data. means filter completed excludes treatment group group within column variable, columns still created groups empty/zero filled.","code":"tplyr_table(tplyr_adsl, TRT01P, where= SAFFL ==\"Y\", cols = SEX) %>% add_layer( group_count(RACE, by = \"Race\") ) %>% add_layer( group_desc(AGE, by = \"Age (Years)\") ) %>% build() %>% kable() tplyr_table(tplyr_adsl, TRT01P, where= SAFFL ==\"Y\", cols = vars(SEX, RACE)) %>% add_layer( group_desc(AGE, by = \"Age (Years)\") ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/table.html","id":"additional-treatment-groups","dir":"Articles","previous_headings":"","what":"Additional Treatment Groups","title":"Tplyr Table Properties","text":"Another important feature works table level addition treatment groups. adding additional treatment groups, ’re able number things: Add ‘treated’ group data can analyze ‘treated’ vs. ‘placebo’ multiple treated cohorts Add ‘total’ group summarize overall study population ’ve added function add_treat_grps() work . function, can create new treatment groups combining existing treatment groups values within treat_var. Additionally, simplify process added abstraction add_treat_grps() named add_total_group() simplify process creating “Total” group. Note example, two new columns added data - var1_Total var1_Treated. summaries individual cohorts left unchanged.","code":"tplyr_table(tplyr_adsl, TRT01P) %>% add_treat_grps('Treated' = c(\"Xanomeline High Dose\", \"Xanomeline Low Dose\")) %>% add_total_group() %>% add_layer( group_desc(AGE, by = \"Age (Years)\") ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/table.html","id":"population-data","dir":"Articles","previous_headings":"","what":"Population Data","title":"Tplyr Table Properties","text":"last important aspect table level properties Tplyr addition population dataset. CDISC standards, datasets like adae contain adverse events occur. means subject experience adverse event, experience adverse event within criteria ’re subsetting , don’t appear dataset. ’re looking proportion subject experienced adverse event compared total number subjects cohort, adae leaves way calculate total - subjects won’t exist data. Tplyr allows provide separate population dataset overcome . Furthermore, also able provide separate population dataset parameter population treatment variable named pop_treat_var, variable names may differ datasets. example, AEREL doesn’t exist adsl, therefore used set_pop_where() remove filter criteria population data. Setting population dataset parameter TRUE removes filter applied population data. set_pop_where() set population data, default parameter used tplyr_table(). logic applies population treatment variable. TRTA exist adsl either, used set_pop_treat_var() change appropriate variable adsl. Note percentage values summary . setting population data, Tplyr now knew use values calculating percentages distinct counts subjects experienced summarized adverse events. Furthermore, population data provided, Tplyr able calculate header N’s properly: Note: ’s expected set_distinct_by() function used population data. make sense use population data denominators unless distinct counts. entire point population data use subject counts, non-distinct counts potentially count multiple records per subject percentage doesn’t make sense.","code":"t <- tplyr_table(tplyr_adae, TRTA, where = AEREL != \"NONE\") %>% set_pop_data(tplyr_adsl) %>% set_pop_treat_var(TRT01A) %>% set_pop_where(TRUE) %>% add_layer( group_count(AEDECOD) %>% set_distinct_by(USUBJID) ) t %>% build() %>% kable() header_n(t) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/table.html","id":"data-completion","dir":"Articles","previous_headings":"","what":"Data Completion","title":"Tplyr Table Properties","text":"creating summary tables, often mock potential values data, even values aren’t present data ’re summarizing. Tplyr best effort . Let’s consider following dataset: Let’s say want create count summary dataset, report PARAM AVISIT. Note data, PARAM==\"HEAD\" collected screening, LUNGS collected Screening, Day -1, Day 5. default, given variables PARAM AVISIT, potential visits dummy rows created 0 filled - meaning results 0 records treatment groups presented. However, might wish present. Perhaps HEAD intended collected Screening visit ’s unnecessary present visits. address , can use set_limit_data_by() function. can see now records HEAD present screening visit. count shift layers, can additionally dig use target variables: effectively limits values present data .","code":"tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_count(AVALC, by = vars(PARAM, AVISIT)) ) %>% build() %>% select(-starts_with('ord')) %>% head(18) %>% kable() tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_count(AVALC, by = vars(PARAM, AVISIT)) %>% set_limit_data_by(PARAM, AVISIT) ) %>% build() %>% select(-starts_with('ord')) %>% head(12) %>% kable() tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_count(AVALC, by = vars(PARAM, AVISIT)) %>% set_limit_data_by(PARAM, AVISIT, AVALC) ) %>% build() %>% select(-starts_with('ord')) %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/articles/table.html","id":"where-to-go-from-here","dir":"Articles","previous_headings":"","what":"Where to Go From Here","title":"Tplyr Table Properties","text":"table level settings control, now ’re ready learn Tplyr offer layer. Learn descriptive statistics layers vignette(\"desc\") Learn count shift layers vignette(\"count\") Learn shift layers vignette(\"shift\") Learn calculating risk differences vignette(\"riskdiff\") Learn sorting Tplyr tables vignette(\"sort\") Learn using Tplyr options vignette(\"options\") finally, learn producing outputting styled tables using Tplyr vignette(\"styled-table\")","code":""},{"path":"https://atorus-research.github.io/Tplyr/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Eli Miller. Author. Mike Stackhouse. Author, maintainer. Ashley Tarasiewicz. Author. Nathan Kosiba. Contributor. Sadchla Mascary. Contributor. Andrew Bates. Contributor. Shiyu Chen. Contributor. Oleksii Mikryukov. Contributor. Atorus Research LLC. Copyright holder.","code":""},{"path":"https://atorus-research.github.io/Tplyr/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Miller E, Stackhouse M, Tarasiewicz (2024). Tplyr: Traceability Focused Grammar Clinical Data Summary. R package version 1.2.1, https://github.com/atorus-research/Tplyr.","code":"@Manual{, title = {Tplyr: A Traceability Focused Grammar of Clinical Data Summary}, author = {Eli Miller and Mike Stackhouse and Ashley Tarasiewicz}, year = {2024}, note = {R package version 1.2.1}, url = {https://github.com/atorus-research/Tplyr}, }"},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"tplyr-","dir":"","previous_headings":"","what":"A Traceability Focused Grammar of Clinical Data Summary","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"Welcome Tplyr! Tplyr traceability minded grammar data format summary. ’s designed simplify creation common clinical summaries help focus present data rather redundant summaries performed. Furthermore, every result Tplyr produces, also produces metadata necessary give traceability source summary. always, welcome feedback. spot bug, like see new feature, documentation unclear - submit issue GitHub right . Take look cheatsheet!","code":""},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"can install Tplyr :","code":"# Install from CRAN: install.packages(\"Tplyr\") # Or install the development version: devtools::install_github(\"https://github.com/atorus-research/Tplyr.git\", ref=\"devel\")"},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"what-is-tplyr","dir":"","previous_headings":"","what":"What is Tplyr?","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"dplyr tidyverse grammar data manipulation. allow ? gives , data analyst, capability easily intuitively approach problem manipulating data analysis ready form. dplyr conceptually breaks things verbs allow focus want . Tplyr designed around similar concept, focus building summary tables common within clinical world. pharmaceutical industry, great deal data presented outputs create similar. part, tables can broken categories: Counting event based variables categories Shifting, just counting change state ‘’ ‘’ Generating descriptive statistics around continuous variable. many tables go clinical submission, tables made combination approaches. Consider demographics table - let’s use example PHUSE project Standard Analyses & Code Sharing - Analyses & Displays Associated Demographics, Disposition, Medications Phase 2-4 Clinical Trials Integrated Summary Documents. look table, can begin breaking output smaller, redundant, components. components can viewed ‘layers’, table whole constructed stacking layers. boxes image represent can begin conceptualize . First Sex, made n (%) counts. Next Age continuous variable, number descriptive statistics, including n, mean, standard deviation, median, quartile 1, quartile 3, min, max, missing values. age, broken categories - n (%) values. Race - counting, Ethnicity - counting Weight - ’re back descriptive statistics. one table, 6 summaries (7 including next page, shown) - 2 different approaches summaries performed. way dplyr grammar data manipulation, Tplyr aims grammar data summary. goal Tplyr allow program summary table like see page, breaking larger problem smaller ‘layers’, combining together like see page. Enough talking - let’s see code. examples, using data PHUSE Test Data Factory based original pilot project submission package. ’ve packaged subsets data Tplyr, can use replicate examples run vignette code . Note: can see replication CDISC pilot using PHUSE Test Data Factory data .","code":"tplyr_table(tplyr_adsl, TRT01P, where = SAFFL == \"Y\") %>% add_layer( group_desc(AGE, by = \"Age (years)\") ) %>% add_layer( group_count(AGEGR1, by = \"Age Categories n (%)\") ) %>% build() %>% kable()"},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"tplyr-is-qualified","dir":"","previous_headings":"","what":"Tplyr is Qualified","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"understand important documentation testing within pharmaceutical world. outside unit testing Tplyr includes entire user-acceptance testing document, requirements established, test-cases written, tests independently programmed executed. hope can leverage work within qualified programming environment, save substantial amount trouble getting . can find qualification document within repository right . ‘uat’ folder additionally contains raw files, programmatic tests, specifications, test cases necessary create report.","code":""},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"the-tldr","dir":"","previous_headings":"","what":"The TL;DR","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"high level benefits using Tplyr: Easy construction table data using intuitive syntax Smart string formatting numbers ’s easily specified user great deal flexibility performed ’s presented, without specifying hundreds parameters","code":""},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"where-to-go-from-here","dir":"","previous_headings":"","what":"Where to go from here?","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"’s quite bit learn! ’ve prepared number vignettes help get need Tplyr. best place start Getting Started vignette vignette(\"Tplyr\") Learn table level settings vignette(\"table\") Learn descriptive statistics layers vignette(\"desc\") Learn count layers vignette(\"count\") Learn shift layers vignette(\"shift\") Learn percentages vignette(\"denom\") Learn calculating risk differences vignette(\"riskdiff\") Learn sorting Tplyr tables vignette(\"sort\") Learn using Tplyr options vignette(\"options\") finally, learn producing outputting styled tables using Tplyr vignette(\"styled-table\") Tplyr version 1.0.0, ’ve packed number new features . deeper dives largest new additions: Learn Tplyr’s traceability metadata vignette(\"metadata\") can extended vignette(\"custom-metadata\") Learn layer templates vignette(\"layer_templates\")","code":""},{"path":"https://atorus-research.github.io/Tplyr/index.html","id":"references","dir":"","previous_headings":"","what":"References","title":"A Traceability Focused Grammar of Clinical Data Summary","text":"building Tplyr, needed additional resources addition personal experience help guide design. PHUSE done great work create guidance standard outputs collaboration multiple pharmaceutical companies FDA. can find resource referenced . Analysis Displays Associated Adverse Events Analyses Displays Associated Demographics, Disposition, Medications Analyses Displays Associated Measures Central Tendency","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/Tplyr.html","id":null,"dir":"Reference","previous_headings":"","what":"A grammar of summary data for clinical reports — Tplyr","title":"A grammar of summary data for clinical reports — Tplyr","text":"`r lifecycle::badge(\"experimental\")`","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/Tplyr.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"A grammar of summary data for clinical reports — Tplyr","text":"'Tplyr' package dedicated simplifying data manipulation necessary create clinical reports. Clinical data summaries can often broken two factors - counting discrete variables (counting shifts state), descriptive statistics around continuous variable. Many reports go clinical report made two scenarios. abstracting process away, 'Tplyr' allows rapidly build tables without worrying underlying data manipulation. 'Tplyr' takes process steps abstracting away programming goes proper presentation, great deal programming time spent. example, 'Tplyr' allows easily control: String formatting Different reports warrant different presentation strings. Programming can get tedious, typically want make sure decimals properly align. 'Tplyr' abstracts process away provides simple interface specify want data presented Treatment groups Need total column? Need group summaries multiple treatments? 'Tplyr' makes simple add additional treatment groups report Denominators n (%) counts often vary based summary performed. 'Tplyr' allows easily control denominators used based common scenarios Sorting Summarizing data one thing, ordering presentation. Tplyr automatically derives sorting variable give data need order table properly. process flexible can easily get want leveraging data characteristics R. Another powerful aspect 'Tplyr' objects . 'Tplyr' format data. Metadata table kept hood, functions allow access information need. example, 'Tplyr' allows calculate access raw numeric data calculations well, easily pick just pieces information need. Lastly, 'Tplyr' built flexible, yet intuitive. common pitfall building tools like automation. much, end enough. 'Tplyr' aims hit sweet spot . Additionally, designed function interfaces clean. Modifier functions offer flexibility need , defaults can set keep code concise. allows quickly assemble table, easily make changes necessary.","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/Tplyr.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"A grammar of summary data for clinical reports — Tplyr","text":"Maintainer: Mike Stackhouse mike.stackhouse@atorusresearch.com (ORCID) Authors: Eli Miller Eli.Miller@AtorusResearch.com (ORCID) Ashley Tarasiewicz Ashley.Tarasiewicz@atorusresearch.com contributors: Nathan Kosiba Nathan.Kosiba@atorusresearch.com (ORCID) [contributor] Sadchla Mascary sadchla.mascary@atorusresearch.com [contributor] Andrew Bates andrew.bates@atorusresearch.com [contributor] Shiyu Chen shiyu.chen@atorusresearch.com [contributor] Oleksii Mikryukov alex.mikryukov@atorusresearch.com [contributor] Atorus Research LLC [copyright holder]","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/Tplyr.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"A grammar of summary data for clinical reports — Tplyr","text":"","code":"# Load in pipe library(magrittr) # Use just the defaults tplyr_table(mtcars, gear) %>% add_layer( group_desc(mpg, by=cyl) ) %>% add_layer( group_count(carb, by=cyl) ) %>% build() #> # A tibble: 36 × 8 #> row_label1 row_label2 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 n \" 1\" \" 8\" \" 2\" 1 1 #> 2 4 Mean (SD) \"21.50 ( … \"26.9… \"28.2… 1 1 #> 3 4 Median \"21.50\" \"25.8… \"28.2… 1 1 #> 4 4 Q1, Q3 \"21.50, 21.5… \"22.8… \"27.1… 1 1 #> 5 4 Min, Max \"21.5, 21.5\" \"21.4… \"26.0… 1 1 #> 6 4 Missing \" 0\" \" 0\" \" 0\" 1 1 #> 7 6 n \" 2\" \" 4\" \" 1\" 1 2 #> 8 6 Mean (SD) \"19.75 ( 2.3… \"19.7… \"19.7… 1 2 #> 9 6 Median \"19.75\" \"20.1… \"19.7… 1 2 #> 10 6 Q1, Q3 \"18.92, 20.5… \"18.8… \"19.7… 1 2 #> # ℹ 26 more rows #> # ℹ 1 more variable: ord_layer_2 # Customize and modify tplyr_table(mtcars, gear) %>% add_layer( group_desc(mpg, by=cyl) %>% set_format_strings( \"n\" = f_str(\"xx\", n), \"Mean (SD)\" = f_str(\"a.a+1 (a.a+2)\", mean, sd, empty='NA'), \"Median\" = f_str(\"a.a+1\", median), \"Q1, Q3\" = f_str(\"a, a\", q1, q3, empty=c(.overall='NA')), \"Min, Max\" = f_str(\"a, a\", min, max), \"Missing\" = f_str(\"xx\", missing) ) ) %>% add_layer( group_count(carb, by=cyl) %>% add_risk_diff( c('5', '3'), c('4', '3') ) %>% set_format_strings( n_counts = f_str('xx (xx%)', n, pct), riskdiff = f_str('xx.xxx (xx.xxx, xx.xxx)', dif, low, high) ) %>% set_order_count_method(\"bycount\") %>% set_ordering_cols('4') %>% set_result_order_var(pct) ) %>% build() #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> # A tibble: 36 × 10 #> row_label1 row_label2 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 n \" 1\" \" 8\" \" 2\" 1 1 #> 2 4 Mean (SD) \"21.50 ( … \"26.9… \"28.2… 1 1 #> 3 4 Median \"21.50\" \"25.8… \"28.2… 1 1 #> 4 4 Q1, Q3 \"22, 22\" \"23, … \"27, … 1 1 #> 5 4 Min, Max \"22, 22\" \"21, … \"26, … 1 1 #> 6 4 Missing \" 0\" \" 0\" \" 0\" 1 1 #> 7 6 n \" 2\" \" 4\" \" 1\" 1 2 #> 8 6 Mean (SD) \"19.75 ( 2.3… \"19.7… \"19.7… 1 2 #> 9 6 Median \"19.75\" \"20.1… \"19.7… 1 2 #> 10 6 Q1, Q3 \"19, 21\" \"19, … \"20, … 1 2 #> # ℹ 26 more rows #> # ℹ 3 more variables: ord_layer_2 , rdiff_5_3 , rdiff_4_3 # A Shift Table tplyr_table(mtcars, am) %>% add_layer( group_shift(vars(row=gear, column=carb), by=cyl) %>% set_format_strings(f_str(\"xxx (xx.xx%)\", n, pct)) ) %>% build() #> # A tibble: 9 × 17 #> row_label1 row_label2 var1_0_1 var1_0_2 var1_0_3 var1_0_4 var1_0_6 var1_0_8 #> #> 1 4 3 \" 1 (33.3… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 2 4 4 \" 0 ( 0.0… \" 2 (6… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 3 4 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 4 6 3 \" 2 (50.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 5 6 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 2 (5… \" 0 ( … \" 0 ( … #> 6 6 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 7 8 3 \" 0 ( 0.0… \" 4 (3… \" 3 (2… \" 5 (4… \" 0 ( … \" 0 ( … #> 8 8 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 9 8 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> # ℹ 9 more variables: var1_1_1 , var1_1_2 , var1_1_3 , #> # var1_1_4 , var1_1_6 , var1_1_8 , ord_layer_index , #> # ord_layer_1 , ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/reference/add_anti_join.html","id":null,"dir":"Reference","previous_headings":"","what":"Add an anti-join onto a tplyr_meta object — add_anti_join","title":"Add an anti-join onto a tplyr_meta object — add_anti_join","text":"anti-join allows tplyr_meta object refer data extracted separate dataset, like population data Tplyr table, unavailable target dataset. primary use case presentation missing subjects, Tplyr table presented using function add_missing_subjects_row(). missing subjects present target data, thus available population data. add_anti_join() function allows provide meta information relevant population data, specify variable used join target dataset find values present population data missing target data.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_anti_join.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add an anti-join onto a tplyr_meta object — add_anti_join","text":"","code":"add_anti_join(meta, join_meta, on)"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_anti_join.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add an anti-join onto a tplyr_meta object — add_anti_join","text":"meta tplyr_meta object referring target data join_meta tplyr_meta object referring population data list quosures containing symbols - likely set USUBJID.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_anti_join.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add an anti-join onto a tplyr_meta object — add_anti_join","text":"tplyr_meta object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_anti_join.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add an anti-join onto a tplyr_meta object — add_anti_join","text":"","code":"tm <- tplyr_meta( rlang::quos(TRT01A, SEX, ETHNIC, RACE), rlang::quos(TRT01A == \"Placebo\", TRT01A == \"SEX\", ETHNIC == \"HISPANIC OR LATINO\") ) tm %>% add_anti_join( tplyr_meta( rlang::quos(TRT01A, ETHNIC), rlang::quos(TRT01A == \"Placebo\", ETHNIC == \"HISPANIC OR LATINO\") ), on = rlang::quos(USUBJID) ) #> tplyr_meta: 4 names, 3 filters #> Names: #> TRT01A, SEX, ETHNIC, RACE #> Filters: #> TRT01A == \"Placebo\", TRT01A == \"SEX\", ETHNIC == \"HISPANIC OR LATINO\" #> Anti-join: #> Join Meta: #> tplyr_meta: 2 names, 2 filters #> Names: #> TRT01A, ETHNIC #> Filters: #> TRT01A == \"Placebo\", ETHNIC == \"HISPANIC OR LATINO\" #> On: #> USUBJID"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":null,"dir":"Reference","previous_headings":"","what":"Attach column headers to a Tplyr output — add_column_headers","title":"Attach column headers to a Tplyr output — add_column_headers","text":"working 'huxtable' tables, column headers can controlled rows data frame. add_column_headers eases process introducing headers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Attach column headers to a Tplyr output — add_column_headers","text":"","code":"add_column_headers(.data, s, header_n = NULL)"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Attach column headers to a Tplyr output — add_column_headers","text":".data data.frame/tibble headers shall attached s text containing intended header string header_n header_n generic data.frame use binding count values. required using token replacement.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Attach column headers to a Tplyr output — add_column_headers","text":"data.frame processed header string elements attached top rows","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Attach column headers to a Tplyr output — add_column_headers","text":"Headers created providing single string. Columns specified delimitting header '|' symbol. Instead specifying destination header, add_column_headers assumes organized columns data frame hand. means use Tplyr::build(), like reorganize default column order (simply alphabetical), simply pass build output dplyr::select dplyr::relocate statement passing add_column_headers. Spanning headers also supported. spanning header overarching header sits across multiple columns. Spanning headers introduced add_column_header providing spanner text (.e. text like sit top row), spanned text (bottom row) within curly brackets ('{}). example, take iris dataset. names: \"Sepal.Length\" \"Sepal.Width\" \"Petal.Length\" \"Petal.Width\" \"Species\" wanted provide header string dataset, spanners help categorization variables, provide following string: \"Sepal {Length | Width} | Petal {Length | Width} | Species\"","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"important-note","dir":"Reference","previous_headings":"","what":"Important note","title":"Attach column headers to a Tplyr output — add_column_headers","text":"Make sure aware order variables prior passing add_column_headers. requirement number column match. rest .","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"development-notes","dir":"Reference","previous_headings":"","what":"Development notes","title":"Attach column headers to a Tplyr output — add_column_headers","text":"features add_column_header intended yet supported: Nested spanners yet supported. spanning row bottom row can currently created Different delimiters indicators spanned group may used future. current choices intuitive, based feedback determined less common characters may necessary.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"token-replacement","dir":"Reference","previous_headings":"","what":"Token Replacement","title":"Attach column headers to a Tplyr output — add_column_headers","text":"function support reading values header_n object Tplyr table adding column headers. Note: order parameters passed token important. first treatment variable cols variables order passed table construction. Use double asterisk \"**\" begining start token another double asterisk close . can separate column parameters token single underscore. example, **group1_flag2_param3** pull count header_n binding group1 treat_var, flag2 first cols argument, param3 second cols argument. can pass fewer arguments token get sum multiple columns. example, **group1** get sum group1 treat_var, cols header_n.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_column_headers.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Attach column headers to a Tplyr output — add_column_headers","text":"","code":"# Load in pipe library(magrittr) library(dplyr) #> #> Attaching package: ‘dplyr’ #> The following objects are masked from ‘package:stats’: #> #> filter, lag #> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union header_string <- \"Sepal {Length | Width} | Petal {Length | Width} | Species\" iris2 <- iris %>% mutate_all(as.character) iris2 %>% add_column_headers(header_string) #> # A tibble: 152 × 5 #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> #> 1 Sepal \"\" Petal \"\" \"\" #> 2 Length \"Width\" Length \"Width\" \"Species\" #> 3 5.1 \"3.5\" 1.4 \"0.2\" \"setosa\" #> 4 4.9 \"3\" 1.4 \"0.2\" \"setosa\" #> 5 4.7 \"3.2\" 1.3 \"0.2\" \"setosa\" #> 6 4.6 \"3.1\" 1.5 \"0.2\" \"setosa\" #> 7 5 \"3.6\" 1.4 \"0.2\" \"setosa\" #> 8 5.4 \"3.9\" 1.7 \"0.4\" \"setosa\" #> 9 4.6 \"3.4\" 1.4 \"0.3\" \"setosa\" #> 10 5 \"3.4\" 1.5 \"0.2\" \"setosa\" #> # ℹ 142 more rows # Example with counts mtcars2 <- mtcars %>% mutate_all(as.character) t <- tplyr_table(mtcars2, vs, cols = am) %>% add_layer( group_count(cyl) ) b_t <- build(t) %>% mutate_all(as.character) count_string <- paste0(\" | V N=**0** {auto N=**0_0** | man N=**0_1**} |\", \" S N=**1** {auto N=**1_0** | man N=**1_1**} | | \") add_column_headers(b_t, count_string, header_n(t)) #> # A tibble: 5 × 7 #> row_label1 var1_0_0 var1_0_1 var1_1_0 var1_1_1 ord_layer_index ord_layer_1 #> #> 1 \"\" \"V N=18\" \"\" \"S N=14\" \"\" \"\" \"\" #> 2 \"\" \"auto N=12\" \"man N=… \"auto N… \"man N=… \"\" \"\" #> 3 \"4\" \" 0 ( 0.0%… \" 1 ( 1… \" 3 ( 4… \" 7 (10… \"1\" \"1\" #> 4 \"6\" \" 0 ( 0.0%… \" 3 ( 5… \" 4 ( 5… \" 0 ( … \"1\" \"2\" #> 5 \"8\" \"12 (100.0%… \" 2 ( 3… \" 0 ( … \" 0 ( … \"1\" \"3\""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_missing_subjects_row.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a missing subject row into a count summary. — add_missing_subjects_row","title":"Add a missing subject row into a count summary. — add_missing_subjects_row","text":"function calculates number subjects missing particular group results. calculation done examining total number subjects potentially available Header N values within result column, finding difference total number subjects present result group. Note accurate results, subject variable needs defined using `set_distinct_by()` function. methods, function instructs distinct results identified.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_missing_subjects_row.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a missing subject row into a count summary. — add_missing_subjects_row","text":"","code":"add_missing_subjects_row(e, fmt = NULL, sort_value = NULL)"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_missing_subjects_row.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a missing subject row into a count summary. — add_missing_subjects_row","text":"e `count_layer` object fmt f_str object used format total row. none provided, display based layer formatting. sort_value value appear ordering column total rows. must numeric value.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_missing_subjects_row.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a missing subject row into a count summary. — add_missing_subjects_row","text":"","code":"tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% add_missing_subjects_row(f_str(\"xxxx\", n)) ) %>% build() #> Warning: \tPopulation data was not set separately from the target data. #> \tMissing subject counts may be misleading in this scenario. #> \tDid you mean to use `set_missing_count() instead? #> # A tibble: 4 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 6 \" 2 ( 13.3%)\" \" 4 ( 33.3%)\" \" 1 ( 20.0… 1 2 #> 3 8 \"12 ( 80.0%)\" \" 0 ( 0.0%)\" \" 2 ( 40.0… 1 3 #> 4 Missing \" \" \" \" \" \" 1 4"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_risk_diff.html","id":null,"dir":"Reference","previous_headings":"","what":"Add risk difference to a count layer — add_risk_diff","title":"Add risk difference to a count layer — add_risk_diff","text":"common requirement summary tables calculate risk difference treatment groups. add_risk_diff allows . underlying risk difference calculations performed using Base R function prop.test - prior using function, sure familiarize functionality.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_risk_diff.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add risk difference to a count layer — add_risk_diff","text":"","code":"add_risk_diff(layer, ..., args = list(), distinct = TRUE)"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_risk_diff.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add risk difference to a count layer — add_risk_diff","text":"layer Layer upon risk difference attached ... Comparison groups, provided character vectors first group comparison, second reference args Arguments passed directly prop.test distinct Logical - Use distinct counts (available).","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_risk_diff.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add risk difference to a count layer — add_risk_diff","text":"add_risk_diff can attached count layer, count layer must constructed first. add_risk_diff allows compare difference treatment group, comparisons based upon values within specified treat_var tplyr_table object. Comparisons specified providing two-element character vectors. can provide many groups want. can also use groups constructed using add_treat_grps add_total_group. first element provided considered 'reference' group (.e. left side comparison), second group considered 'comparison'. like see risk difference 'T1 - Placebo', specify c('T1', 'Placebo'). Tplyr forms two-way table background, runs prop.test appropriately. Similar way display layers specified, exact values format like risk difference display set using set_format_strings. controls values format risk difference displayed. Risk difference formats set within set_format_strings using name 'riskdiff'. 5 variables choose data presentation: comp Probability left hand side group (.e. comparison) ref Probability right hand side group (.e. reference) dif Difference comparison - reference low Lower end confidence interval (default 95%, override args paramter) high Upper end confidence interval (default 95%, override args paramter) Use variable names forming f_str objects. default presentation, string format specified, : f_str('xx.xxx (xx.xxx, xx.xxx)', dif, low, high) Note - within Tplyr, can account negatives allowing extra space within integer side settings. help alignment. columns specified Tplyr table, risk difference comparisons still take place groups within treat_var variable - instead calculated treating cols variables variables. Just like tplyr layers , risk difference transposed display risk difference separate variables cols variables. distinct TRUE (default), calculations take place distinct counts, available. Otherwise, non-distinct counts used. One final note - prop.test may throw quite warnings. natural, alerts enough data approximations correct. may unnerving coming SAS programming world, R trying alert values provided enough data truly statistically accurate.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_risk_diff.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add risk difference to a count layer — add_risk_diff","text":"","code":"library(magrittr) ## Two group comparisons with default options applied t <- tplyr_table(mtcars, gear) # Basic risk diff for two groups, using defaults l1 <- group_count(t, carb) %>% # Compare 3 vs. 4, 3 vs. 5 add_risk_diff( c('3', '4'), c('3', '5') ) # Build and show output add_layers(t, l1) %>% build() #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> # A tibble: 6 × 8 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index rdiff_3_4 rdiff_3_5 #> #> 1 1 3 ( 20.0%) 4 ( 33.3%) 0 ( 0.0… 1 \"-0.133 … \" 0.200 … #> 2 2 4 ( 26.7%) 4 ( 33.3%) 2 ( 40.0… 1 \"-0.067 … \"-0.133 … #> 3 3 3 ( 20.0%) 0 ( 0.0%) 0 ( 0.0… 1 \" 0.200 … \" 0.200 … #> 4 4 5 ( 33.3%) 4 ( 33.3%) 1 ( 20.0… 1 \" 0.000 … \" 0.133 … #> 5 6 0 ( 0.0%) 0 ( 0.0%) 1 ( 20.0… 1 \" 0.000 … \"-0.200 … #> 6 8 0 ( 0.0%) 0 ( 0.0%) 1 ( 20.0… 1 \" 0.000 … \"-0.200 … #> # ℹ 1 more variable: ord_layer_1 ## Specify custom formats and display variables t <- tplyr_table(mtcars, gear) # Create the layer with custom formatting l2 <- group_count(t, carb) %>% # Compare 3 vs. 4, 3 vs. 5 add_risk_diff( c('3', '4'), c('3', '5') ) %>% set_format_strings( 'n_counts' = f_str('xx (xx.x)', n, pct), 'riskdiff' = f_str('xx.xxx, xx.xxx, xx.xxx, xx.xxx, xx.xxx', comp, ref, dif, low, high) ) # Build and show output add_layers(t, l2) %>% build() #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> # A tibble: 6 × 8 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index rdiff_3_4 rdiff_3_5 #> #> 1 1 \" 3 (20.0)\" \" 4 (33.3)\" \" 0 ( … 1 \" 0.200,… \" 0.200,… #> 2 2 \" 4 (26.7)\" \" 4 (33.3)\" \" 2 (4… 1 \" 0.267,… \" 0.267,… #> 3 3 \" 3 (20.0)\" \" 0 ( 0.0)\" \" 0 ( … 1 \" 0.200,… \" 0.200,… #> 4 4 \" 5 (33.3)\" \" 4 (33.3)\" \" 1 (2… 1 \" 0.333,… \" 0.333,… #> 5 6 \" 0 ( 0.0)\" \" 0 ( 0.0)\" \" 1 (2… 1 \" 0.000,… \" 0.000,… #> 6 8 \" 0 ( 0.0)\" \" 0 ( 0.0)\" \" 1 (2… 1 \" 0.000,… \" 0.000,… #> # ℹ 1 more variable: ord_layer_1 ## Passing arguments to prop.test t <- tplyr_table(mtcars, gear) # Create the layer with args option l3 <- group_count(t, carb) %>% # Compare 3 vs. 4, 4 vs. 5 add_risk_diff( c('3', '4'), c('3', '5'), args = list(conf.level = 0.9, correct=FALSE, alternative='less') ) # Build and show output add_layers(t, l3) %>% build() #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> # A tibble: 6 × 8 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index rdiff_3_4 rdiff_3_5 #> #> 1 1 3 ( 20.0%) 4 ( 33.3%) 0 ( 0.0… 1 \"-0.133 … \" 0.200 … #> 2 2 4 ( 26.7%) 4 ( 33.3%) 2 ( 40.0… 1 \"-0.067 … \"-0.133 … #> 3 3 3 ( 20.0%) 0 ( 0.0%) 0 ( 0.0… 1 \" 0.200 … \" 0.200 … #> 4 4 5 ( 33.3%) 4 ( 33.3%) 1 ( 20.0… 1 \" 0.000 … \" 0.133 … #> 5 6 0 ( 0.0%) 0 ( 0.0%) 1 ( 20.0… 1 \" 0.000 … \"-0.200 … #> 6 8 0 ( 0.0%) 0 ( 0.0%) 1 ( 20.0… 1 \" 0.000 … \"-0.200 … #> # ℹ 1 more variable: ord_layer_1 "},{"path":"https://atorus-research.github.io/Tplyr/reference/add_total_row.html","id":null,"dir":"Reference","previous_headings":"","what":"Add a Total row into a count summary. — add_total_row","title":"Add a Total row into a count summary. — add_total_row","text":"Adding total row creates additional observation count summary presents total counts (.e. n's summarized). format total row formatted way count strings.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_total_row.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add a Total row into a count summary. — add_total_row","text":"","code":"add_total_row(e, fmt = NULL, count_missings = TRUE, sort_value = NULL)"},{"path":"https://atorus-research.github.io/Tplyr/reference/add_total_row.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add a Total row into a count summary. — add_total_row","text":"e count_layer object fmt f_str object used format total row. none provided, display based layer formatting. count_missings Whether ignore named arguments passed `set_count_missing()` calculating counts total row. useful need exclude/include missing counts total row. Defaults TRUE meaning total row ignore values. sort_value value appear ordering column total rows. must numeric value.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_total_row.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add a Total row into a count summary. — add_total_row","text":"Totals calculated using grouping variables, including treat_var cols table level. variables included, grouping total application denominators becomes ambiguous. warned specifically percent included format. rectify , use set_denoms_by(), grouping add_total_row() updated accordingly. Note using add_total_row() set_pop_data(), call add_total_row() calling set_pop_data(), otherwise potential unexpected behaivior treatment groups.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/add_total_row.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add a Total row into a count summary. — add_total_row","text":"","code":"# Load in Pipe library(magrittr) tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% add_total_row(f_str(\"xxxx\", n)) ) %>% build() #> # A tibble: 4 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 6 \" 2 ( 13.3%)\" \" 4 ( 33.3%)\" \" 1 ( 20.0… 1 2 #> 3 8 \"12 ( 80.0%)\" \" 0 ( 0.0%)\" \" 2 ( 40.0… 1 3 #> 4 Total \" 15\" \" 12\" \" 5\" 1 4"},{"path":"https://atorus-research.github.io/Tplyr/reference/append_metadata.html","id":null,"dir":"Reference","previous_headings":"","what":"Append the Tplyr table metadata dataframe — append_metadata","title":"Append the Tplyr table metadata dataframe — append_metadata","text":"append_metadata() allows user extend Tplyr metadata data frame user provided data. tables, Tplyr may able provided data, user may extend table summaries, statistics, etc. function allows user extend tplyr_table's metadata metadata content using custom data frames created using tplyr_meta object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/append_metadata.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Append the Tplyr table metadata dataframe — append_metadata","text":"","code":"append_metadata(t, meta)"},{"path":"https://atorus-research.github.io/Tplyr/reference/append_metadata.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Append the Tplyr table metadata dataframe — append_metadata","text":"t tplyr_table object meta dataframe fitting specifications details section function","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/append_metadata.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Append the Tplyr table metadata dataframe — append_metadata","text":"tplyr_table object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/append_metadata.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Append the Tplyr table metadata dataframe — append_metadata","text":"advanced feature Tplyr, ownership user make sure metadata data frame assembled properly. restrictions applied append_metadata() meta must column named row_id, values row_id duplicates row_id value already present Tplyr metadata dataframe. tplyr_meta() objects align constructed dataframes using row_id output dataset column name. , tplyr_meta() objects inserted data frame using list column.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/append_metadata.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Append the Tplyr table metadata dataframe — append_metadata","text":"","code":"t <- tplyr_table(mtcars, gear) %>% add_layer( group_desc(wt) ) t %>% build(metadata=TRUE) #> # A tibble: 6 × 7 #> row_id row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 d1_1 n \" 15\" \" 12\" \" 5\" 1 1 #> 2 d2_1 Mean (SD) \"3.8926 (0.83299)\" \"2.61… \"2.63… 1 2 #> 3 d3_1 Median \"3.7300\" \"2.70… \"2.77… 1 3 #> 4 d4_1 Q1, Q3 \"3.4500, 3.9575\" \"2.13… \"2.14… 1 4 #> 5 d5_1 Min, Max \"2.465, 5.424\" \"1.61… \"1.51… 1 5 #> 6 d6_1 Missing \" 0\" \" 0\" \" 0\" 1 6 m <- tibble::tibble( row_id = c('x1_1'), var1_3 = list(tplyr_meta(rlang::quos(a, b, c), rlang::quos(a==1, b==2, c==3))) ) append_metadata(t, m) #> *** tplyr_table *** #> Target (data.frame): #> \tName: mtcars #> \tRows: 32 #> \tColumns: 11 #> treat_var variable (quosure) #> \tgear #> header_n: 3 header groups #> treat_grps groupings (list) #> Table Columns (cols): #> where: TRUE #> Number of layer(s): 1 #> layer_output: 0"},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_conditional_format.html","id":null,"dir":"Reference","previous_headings":"","what":"Conditional reformatting of a pre-populated string of numbers — apply_conditional_format","title":"Conditional reformatting of a pre-populated string of numbers — apply_conditional_format","text":"function allows conditionally re-format string numbers based numeric value within string . selecting \"format group\", targeting specific number within string, user can establish condition upon provided replacement string can used. Either entire replacement can used replace entire string, replacement text can refill \"format group\" preserving original width alignment target string.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_conditional_format.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Conditional reformatting of a pre-populated string of numbers — apply_conditional_format","text":"","code":"apply_conditional_format( string, format_group, condition, replacement, full_string = FALSE )"},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_conditional_format.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Conditional reformatting of a pre-populated string of numbers — apply_conditional_format","text":"string Target character vector text may replaced format_group integer representing targeted numeric field within string, numbered left right condition expression, using variable name 'x' target variable within condition replacement string use replacement value full_string TRUE full string replaced, FALSE replacement done within format group","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_conditional_format.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Conditional reformatting of a pre-populated string of numbers — apply_conditional_format","text":"character vector","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_conditional_format.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Conditional reformatting of a pre-populated string of numbers — apply_conditional_format","text":"","code":"string <- c(\" 0 (0.0%)\", \" 8 (9.3%)\", \"78 (90.7%)\") apply_conditional_format(string, 2, x == 0, \" 0 \", full_string=TRUE) #> [1] \" 0 \" \" 8 (9.3%)\" \"78 (90.7%)\" apply_conditional_format(string, 2, x < 1, \"(<1%)\") #> [1] \" 0 (<1%)\" \" 8 (9.3%)\" \"78 (90.7%)\""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_formats.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply Format Strings outside of a Tplyr table — apply_formats","title":"Apply Format Strings outside of a Tplyr table — apply_formats","text":"f_str object Tplyr used drive formatting outputs strings within Tplyr table. function allows user use interface apply formatted string data frame within dplyr::mutate() context.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_formats.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply Format Strings outside of a Tplyr table — apply_formats","text":"","code":"apply_formats(format_string, ..., empty = c(.overall = \"\"))"},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_formats.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply Format Strings outside of a Tplyr table — apply_formats","text":"format_string desired display format. X's indicate digits. left, number x's indicates integer length. right, number x's controls decimal precision rounding. Variables inferred separation 'x' values decimal. ... variables formatted using format specified format_string. must numeric variables. empty string display numeric data available. Use single element character vector, element named '.overall' instead replace whole string.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_formats.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Apply Format Strings outside of a Tplyr table — apply_formats","text":"Character vector formatted values","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_formats.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Apply Format Strings outside of a Tplyr table — apply_formats","text":"Note auto-precision currently supported within apply_formats()","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_formats.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Apply Format Strings outside of a Tplyr table — apply_formats","text":"","code":"library(dplyr) mtcars %>% head() %>% mutate( fmt_example = apply_formats('xxx (xx.x)', hp, wt) ) #> mpg cyl disp hp drat wt qsec vs am gear carb #> Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4 #> Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4 #> Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1 #> Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1 #> Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2 #> Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1 #> fmt_example #> Mazda RX4 110 ( 2.6) #> Mazda RX4 Wag 110 ( 2.9) #> Datsun 710 93 ( 2.3) #> Hornet 4 Drive 110 ( 3.2) #> Hornet Sportabout 175 ( 3.4) #> Valiant 105 ( 3.5)"},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_row_masks.html","id":null,"dir":"Reference","previous_headings":"","what":"Replace repeating row label variables with blanks in preparation for display. — apply_row_masks","title":"Replace repeating row label variables with blanks in preparation for display. — apply_row_masks","text":"Depending display package used, row label values may need blanked repeating. gives data frame supporting table appearance grouping variables grouped together blocks. apply_row_masks work blanking value row_label variable current value equal value . Note - apply_row_masks assumes data frame already sorted therefore applied data frame final sort sequence.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_row_masks.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Replace repeating row label variables with blanks in preparation for display. — apply_row_masks","text":"","code":"apply_row_masks(dat, row_breaks = FALSE, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_row_masks.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Replace repeating row label variables with blanks in preparation for display. — apply_row_masks","text":"dat Data.frame / tibble mask repeating row_labels row_breaks Boolean - set TRUE insert row breaks ... Variable used determine row-breaks inserted. Breaks inserted group variables changes values. determined dataset order, sorting done prior using apply_row_masks. left empty, ord_layer_index used.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_row_masks.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Replace repeating row label variables with blanks in preparation for display. — apply_row_masks","text":"tibble blanked rows values repeating","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/apply_row_masks.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Replace repeating row label variables with blanks in preparation for display. — apply_row_masks","text":"Additionally, apply_row_masks can add row breaks layer. Row breaks inserted blank rows. relies \"break \" variables (submitted via ...) constructed build still attached dataset. additional order variable attached named ord_break, output dataset sorted properly insert row breaks layers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/build.html","id":null,"dir":"Reference","previous_headings":"","what":"Trigger the execution of the tplyr_table — build","title":"Trigger the execution of the tplyr_table — build","text":"functions used assemble tplyr_table object layers trigger processing data. Rather, lazy execution style used allow construct table explicitly state data processing happen. build triggers event.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/build.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Trigger the execution of the tplyr_table — build","text":"","code":"build(x, metadata = FALSE)"},{"path":"https://atorus-research.github.io/Tplyr/reference/build.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Trigger the execution of the tplyr_table — build","text":"x tplyr_table object metadata Trigger build metadata. Defaults FALSE","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/build.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Trigger the execution of the tplyr_table — build","text":"executed tplyr_table","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/build.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Trigger the execution of the tplyr_table — build","text":"build command executed, data processing commences. pre-processing necessary within table environment takes place first. Next, layers begins executing. layers complete executing, output layer stacked resulting data frame. process complete, post-processing necessary within table environment takes place, final output can delivered. Metadata traceability information kept within layer environments, allows investigation source resulting datapoints. example, numeric data summaries performed maintained accessible within layer using get_numeric_data. `metadata` option build trigger construction traceability metadata constructed data frame. Essentially, every \"result\" Tplyr produces, Tplyr can also generate steps necessary obtain source data produced result input. information, see vignette(\"metadata\").","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/build.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Trigger the execution of the tplyr_table — build","text":"","code":"# Load in Pipe library(magrittr) tplyr_table(iris, Species) %>% add_layer( group_desc(Sepal.Length, by = \"Sepal Length\") ) %>% add_layer( group_desc(Sepal.Width, by = \"Sepal Width\") ) %>% build() #> # A tibble: 12 × 8 #> row_label1 row_label2 var1_setosa var1_versicolor var1_virginica #> #> 1 Sepal Length n \" 50\" \" 50\" \" 50\" #> 2 Sepal Length Mean (SD) \"5.01 (0.352)\" \"5.94 (0.516)\" \"6.59 (0.636)\" #> 3 Sepal Length Median \"5.00\" \"5.90\" \"6.50\" #> 4 Sepal Length Q1, Q3 \"4.80, 5.20\" \"5.60, 6.30\" \"6.23, 6.90\" #> 5 Sepal Length Min, Max \"4.3, 5.8\" \"4.9, 7.0\" \"4.9, 7.9\" #> 6 Sepal Length Missing \" 0\" \" 0\" \" 0\" #> 7 Sepal Width n \" 50\" \" 50\" \" 50\" #> 8 Sepal Width Mean (SD) \"3.43 (0.379)\" \"2.77 (0.314)\" \"2.97 (0.322)\" #> 9 Sepal Width Median \"3.40\" \"2.80\" \"3.00\" #> 10 Sepal Width Q1, Q3 \"3.20, 3.68\" \"2.52, 3.00\" \"2.80, 3.18\" #> 11 Sepal Width Min, Max \"2.3, 4.4\" \"2.0, 3.4\" \"2.2, 3.8\" #> 12 Sepal Width Missing \" 0\" \" 0\" \" 0\" #> # ℹ 3 more variables: ord_layer_index , ord_layer_1 , #> # ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/reference/by.html","id":null,"dir":"Reference","previous_headings":"","what":"Set or return by layer binding — get_by","title":"Set or return by layer binding — get_by","text":"Set return layer binding","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/by.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set or return by layer binding — get_by","text":"","code":"get_by(layer) set_by(layer, by)"},{"path":"https://atorus-research.github.io/Tplyr/reference/by.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set or return by layer binding — get_by","text":"layer tplyr_layer object string, variable name, list variable names supplied using dplyr::vars.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/by.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set or return by layer binding — get_by","text":"get_by, binding supplied layer. set_by modified layer environment.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/by.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set or return by layer binding — get_by","text":"","code":"# Load in pipe library(magrittr) iris$Species2 <- iris$Species lay <- tplyr_table(iris, Species) %>% group_count(Species) %>% set_by(vars(Species2, Sepal.Width))"},{"path":"https://atorus-research.github.io/Tplyr/reference/collapse_row_labels.html","id":null,"dir":"Reference","previous_headings":"","what":"Collapse row labels into a single column — collapse_row_labels","title":"Collapse row labels into a single column — collapse_row_labels","text":"generalized post processing function allows take groups variables collapse single column. Repeating values split separate rows, level nesting, specified indentation level can applied.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/collapse_row_labels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collapse row labels into a single column — collapse_row_labels","text":"","code":"collapse_row_labels(x, ..., indent = \" \", target_col = row_label)"},{"path":"https://atorus-research.github.io/Tplyr/reference/collapse_row_labels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collapse row labels into a single column — collapse_row_labels","text":"x Input data frame ... Row labels collapsed indent Indentation string used, multiplied indentation level target_col desired name output column containing collapsed row labels","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/collapse_row_labels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Collapse row labels into a single column — collapse_row_labels","text":"data.frame row labels collapsed single column","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/collapse_row_labels.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Collapse row labels into a single column — collapse_row_labels","text":"","code":"x <- tibble::tribble( ~row_label1, ~row_label2, ~row_label3, ~row_label4, ~var1, \"A\", \"C\", \"G\", \"M\", 1L, \"A\", \"C\", \"G\", \"N\", 2L, \"A\", \"C\", \"H\", \"O\", 3L, \"A\", \"D\", \"H\", \"P\", 4L, \"A\", \"D\", \"I\", \"Q\", 5L, \"A\", \"D\", \"I\", \"R\", 6L, \"B\", \"E\", \"J\", \"S\", 7L, \"B\", \"E\", \"J\", \"T\", 8L, \"B\", \"E\", \"K\", \"U\", 9L, \"B\", \"F\", \"K\", \"V\", 10L, \"B\", \"F\", \"L\", \"W\", 11L ) collapse_row_labels(x, row_label1, row_label2, row_label3, row_label4) #> # A tibble: 35 × 2 #> row_label var1 #> #> 1 \"A\" NA #> 2 \" C\" NA #> 3 \" G\" NA #> 4 \" M\" 1 #> 5 \" N\" 2 #> 6 \"A\" NA #> 7 \" C\" NA #> 8 \" H\" NA #> 9 \" O\" 3 #> 10 \"A\" NA #> # ℹ 25 more rows collapse_row_labels(x, row_label1, row_label2, row_label3) #> # A tibble: 19 × 3 #> row_label row_label4 var1 #> #> 1 \"A\" \"\" NA #> 2 \" C\" \"\" NA #> 3 \" G\" \"M\" 1 #> 4 \" G\" \"N\" 2 #> 5 \" H\" \"O\" 3 #> 6 \"A\" \"\" NA #> 7 \" D\" \"\" NA #> 8 \" H\" \"P\" 4 #> 9 \" I\" \"Q\" 5 #> 10 \" I\" \"R\" 6 #> 11 \"B\" \"\" NA #> 12 \" E\" \"\" NA #> 13 \" J\" \"S\" 7 #> 14 \" J\" \"T\" 8 #> 15 \" K\" \"U\" 9 #> 16 \"B\" \"\" NA #> 17 \" F\" \"\" NA #> 18 \" K\" \"V\" 10 #> 19 \" L\" \"W\" 11 collapse_row_labels(x, row_label1, row_label2, indent = \" \", target_col = rl) #> # A tibble: 13 × 4 #> rl row_label3 row_label4 var1 #> #> 1 \"A\" \"\" \"\" NA #> 2 \" C\" \"G\" \"M\" 1 #> 3 \" C\" \"G\" \"N\" 2 #> 4 \" C\" \"H\" \"O\" 3 #> 5 \" D\" \"H\" \"P\" 4 #> 6 \" D\" \"I\" \"Q\" 5 #> 7 \" D\" \"I\" \"R\" 6 #> 8 \"B\" \"\" \"\" NA #> 9 \" E\" \"J\" \"S\" 7 #> 10 \" E\" \"J\" \"T\" 8 #> 11 \" E\" \"K\" \"U\" 9 #> 12 \" F\" \"K\" \"V\" 10 #> 13 \" F\" \"L\" \"W\" 11"},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a f_str object — f_str","title":"Create a f_str object — f_str","text":"f_str objects intended used within function set_format_strings. f_str object carries information powers significant amount layer processing. format_string parameter capable controlling display data point decimal precision. variables provided ... control data points used populate string formatted output.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a f_str object — f_str","text":"","code":"f_str(format_string, ..., empty = c(.overall = \"\"))"},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a f_str object — f_str","text":"format_string desired display format. X's indicate digits. left, number x's indicates integer length. right, number x's controls decimal precision rounding. Variables inferred separation 'x' values decimal. ... variables formatted using format specified format_string. empty string display numeric data available. desc layers, unnamed character vector populate within provided format string, set width fitted numbers. Use single element character vector, element named '.overall' instead replace whole string.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a f_str object — f_str","text":"f_str object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create a f_str object — f_str","text":"Format strings one powerful components 'Tplyr'. Traditionally, converting numeric values strings presentation can consume good deal time. Values decimals need align rows, rounding trimming sometimes forgotten - can become tedious mess realistically important part analysis performed. 'Tplyr' makes process simple can, still allowing flexibility user. Tplyr provides manual automatic decimal precision formatting. display numbers resulting data frame controlled format_string parameter. manual precision, just like dummy values may presented mocks, integer decimal precision specified user providing string 'x's like numbers formatted. like 2 integers 3 decimal places, specify string 'xx.xxx'. 'Tplyr' work get numbers right place. take step , automatic decimal precision can also obtained based collected precision within data. creating tables results vary parameter, different results may call different degrees precision. use automatic precision, use single '' either integer decimal side. like use increased precision (.e. like mean collected precision +1), use '+1'. like integer decimal precision based data collected, can use format like '.' - collected+1 decimal precision, '.+1'. can mix match manual formats well, making format strings 'xx.+1'. want two numbers line, provide two sets x's. example, presenting value like \"mean (sd)\" - provide string 'xx.xx (xx.xxx)', perhaps '.+1 (.+2). Note able provide different integer lengths different decimal precision two values. format string independent relates format specified. described , using 'x' '', character within format string stay stationary. example, format string 'xx (xxx.x)', number may format '12 ( 34.5)'. left side parenthesis stays fixed. displays, may want parenthesis 'hug' number. Following example, allotting 3 spaces integer within parentheses, parentehsis shift right, making numbers appear '12 (34.5)'. Using f_str() can achieve using capital 'X' ''. example, format string 'xx (XXX.x)'. two rules using 'parenthesis hugging': Capital letters used integer side number character must precede capital letter, otherwise character 'hug' parameters f_str call specify values fill x's. f_str objects used slightly differently different layers. declaring format string within count layer, f_str() expects see values n distinct_n event distinct counts, pct distinct_pct event distinct percentages, total distinct_total denominator calculations. Note f_str() count layer '' '' based n counts, therefore make sense use percentages. descriptive statistic layers, f_str parameters refer names summaries performed, either built defaults, custom summaries declared using set_custom_summaries(). See set_format_strings() notes layers specific implementation. f_str() may also used outside Tplyr table. function apply_formats() allows apply f_str within context dplyr::mutate() generally vectorized function.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":"valid-f-str-variables-by-layer-type","dir":"Reference","previous_headings":"","what":"Valid f_str() Variables by Layer Type","title":"Create a f_str object — f_str","text":"Valid variables allowed within ... parameter f_str() differ layer type. Count layers n pct total distinct_n distinct_pct distinct_total Shift layers n pct total Desc layers n mean sd median var min max iqr q1 q3 missing Custom summaries created set_custom_summaries()","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/f_str.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a f_str object — f_str","text":"","code":"f_str(\"xx.x (xx.x)\", mean, sd) #> *** Format String *** #> xx.x (xx.x) #> *** vars, extracted formats, and settings *** #> mean formated as: xx.x #> \tinteger length: 2 #> \tdecimal length: 1 #> sd formated as: xx.x #> \tinteger length: 2 #> \tdecimal length: 1 #> Total Format Size: 11 f_str(\"a.a+1 (a.a+2)\", mean, sd) #> *** Format String *** #> a.a+1 (a.a+2) #> *** vars, extracted formats, and settings *** #> mean formated as: a.a+1 #> \tinteger length: 0 #> \tdecimal length: 1 #> sd formated as: a.a+2 #> \tinteger length: 0 #> \tdecimal length: 2 #> Total Format Size: 13 f_str(\"xx.a (xx.a+1)\", mean, sd) #> *** Format String *** #> xx.a (xx.a+1) #> *** vars, extracted formats, and settings *** #> mean formated as: xx.a #> \tinteger length: 2 #> \tdecimal length: 0 #> sd formated as: xx.a+1 #> \tinteger length: 2 #> \tdecimal length: 1 #> Total Format Size: 13 f_str(\"xx.x, xx.x, xx.x\", q1, median, q3) #> *** Format String *** #> xx.x, xx.x, xx.x #> *** vars, extracted formats, and settings *** #> q1 formated as: xx.x #> \tinteger length: 2 #> \tdecimal length: 1 #> median formated as: xx.x #> \tinteger length: 2 #> \tdecimal length: 1 #> q3 formated as: xx.x #> \tinteger length: 2 #> \tdecimal length: 1 #> Total Format Size: 16 f_str(\"xx (XXX.x%)\", n, pct) #> *** Format String *** #> xx (XXX.x%) #> *** vars, extracted formats, and settings *** #> n formated as: xx #> \tinteger length: 2 #> \tdecimal length: 0 #> pct formated as: (XXX.x #> \tinteger length: 4 #> \tdecimal length: 1 #> Total Format Size: 11 f_str(\"a.a+1 (A.a+2)\", mean, sd) #> *** Format String *** #> a.a+1 (A.a+2) #> *** vars, extracted formats, and settings *** #> mean formated as: a.a+1 #> \tinteger length: 0 #> \tdecimal length: 1 #> sd formated as: (A.a+2 #> \tinteger length: 0 #> \tdecimal length: 2 #> Total Format Size: 13"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_data_labels.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Data Labels — get_data_labels","title":"Get Data Labels — get_data_labels","text":"Get labels data sets included Tplyr.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_data_labels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Data Labels — get_data_labels","text":"","code":"get_data_labels(data)"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_data_labels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Data Labels — get_data_labels","text":"data Tplyr data set.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_data_labels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get Data Labels — get_data_labels","text":"data.frame columns `name` `label` containing names labels column.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_result.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract the result metadata of a Tplyr table — get_meta_result","title":"Extract the result metadata of a Tplyr table — get_meta_result","text":"Given row_id value result column, function return tplyr_meta object associated 'cell'.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_result.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract the result metadata of a Tplyr table — get_meta_result","text":"","code":"get_meta_result(x, row_id, column, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_result.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract the result metadata of a Tplyr table — get_meta_result","text":"x built Tplyr table dataframe row_id row_id value desired cell, provided character string column result column interest, provided character string ... additional arguments","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_result.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract the result metadata of a Tplyr table — get_meta_result","text":"tplyr_meta object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_result.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract the result metadata of a Tplyr table — get_meta_result","text":"Tplyr table built metadata=TRUE option specified, metadata assembled behind scenes provide traceability result cell derived. functions get_meta_result() get_meta_subset() allow access metadata using ID provided row_id column column name result like access. purpose row_id variable instead simple row index provide sort resistant reference originating column, output Tplyr table can sorted order metadata still easily accessible. tplyr_meta object provided list two elements - names filters. metadata contain every column target data.frame Tplyr table factored specified result cell, filters contains necessary filters subset data summarized create specified result cell. get_meta_subset() additionally provides parameter specify additional columns like include returned subset data frame.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_result.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract the result metadata of a Tplyr table — get_meta_result","text":"","code":"t <- tplyr_table(mtcars, cyl) %>% add_layer( group_desc(hp) ) dat <- t %>% build(metadata = TRUE) get_meta_result(t, 'd1_1', 'var1_4') #> tplyr_meta: 2 names, 3 filters #> Names: #> cyl, hp #> Filters: #> cyl == c(\"4\"), TRUE, TRUE m <- t$metadata dat <- t$target get_meta_result(t, 'd1_1', 'var1_4') #> tplyr_meta: 2 names, 3 filters #> Names: #> cyl, hp #> Filters: #> cyl == c(\"4\"), TRUE, TRUE"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_subset.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract the subset of data based on result metadata — get_meta_subset","title":"Extract the subset of data based on result metadata — get_meta_subset","text":"Given row_id value result column, function return subset data referenced tplyr_meta object associated 'cell', provides traceability tie result source.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_subset.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract the subset of data based on result metadata — get_meta_subset","text":"","code":"get_meta_subset(x, row_id, column, add_cols = vars(USUBJID), ...) # S3 method for data.frame get_meta_subset( x, row_id, column, add_cols = vars(USUBJID), target = NULL, pop_data = NULL, ... ) # S3 method for tplyr_table get_meta_subset(x, row_id, column, add_cols = vars(USUBJID), ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_subset.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract the subset of data based on result metadata — get_meta_subset","text":"x built Tplyr table dataframe row_id row_id value desired cell, provided character string column result column interest, provided character string add_cols Additional columns include subset data.frame output ... additional arguments target data frame subset (pulled Tplyr table) pop_data data frame subset anti-join (pulled Tplyr table)","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_subset.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract the subset of data based on result metadata — get_meta_subset","text":"data.frame","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_subset.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract the subset of data based on result metadata — get_meta_subset","text":"Tplyr table built metadata=TRUE option specified, metadata assembled behind scenes provide traceability result cell derived. functions get_meta_result() get_meta_subset() allow access metadata using ID provided row_id column column name result like access. purpose row_id variable instead simple row index provide sort resistant reference originating column, output Tplyr table can sorted order metadata still easily accessible. tplyr_meta object provided list two elements - names filters. metadata contain every column target data.frame Tplyr table factored specified result cell, filters contains necessary filters subset data summarized create specified result cell. get_meta_subset() additionally provides parameter specify additional columns like include returned subset data frame.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_meta_subset.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract the subset of data based on result metadata — get_meta_subset","text":"","code":"t <- tplyr_table(mtcars, cyl) %>% add_layer( group_desc(hp) ) dat <- t %>% build(metadata = TRUE) get_meta_subset(t, 'd1_1', 'var1_4', add_cols = dplyr::vars(carb)) #> carb cyl hp #> Datsun 710 1 4 93 #> Merc 240D 2 4 62 #> Merc 230 2 4 95 #> Fiat 128 1 4 66 #> Honda Civic 2 4 52 #> Toyota Corolla 1 4 65 #> Toyota Corona 1 4 97 #> Fiat X1-9 1 4 66 #> Porsche 914-2 2 4 91 #> Lotus Europa 2 4 113 #> Volvo 142E 2 4 109 m <- t$metadata dat <- t$target get_meta_subset(t, 'd1_1', 'var1_4', add_cols = dplyr::vars(carb), target = target) #> carb cyl hp #> Datsun 710 1 4 93 #> Merc 240D 2 4 62 #> Merc 230 2 4 95 #> Fiat 128 1 4 66 #> Honda Civic 2 4 52 #> Toyota Corolla 1 4 65 #> Toyota Corona 1 4 97 #> Fiat X1-9 1 4 66 #> Porsche 914-2 2 4 91 #> Lotus Europa 2 4 113 #> Volvo 142E 2 4 109"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_metadata.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the metadata dataframe from a tplyr_table — get_metadata","title":"Get the metadata dataframe from a tplyr_table — get_metadata","text":"Pull metadata dataframe tplyr_table work directly","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_metadata.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the metadata dataframe from a tplyr_table — get_metadata","text":"","code":"get_metadata(t)"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_metadata.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the metadata dataframe from a tplyr_table — get_metadata","text":"t Tplyr table metadata built","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_metadata.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the metadata dataframe from a tplyr_table — get_metadata","text":"Tplyr metadata dataframe","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_metadata.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the metadata dataframe from a tplyr_table — get_metadata","text":"","code":"t <- tplyr_table(mtcars, gear) %>% add_layer( group_desc(wt) ) t %>% build(metadata=TRUE) #> # A tibble: 6 × 7 #> row_id row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 d1_1 n \" 15\" \" 12\" \" 5\" 1 1 #> 2 d2_1 Mean (SD) \"3.8926 (0.83299)\" \"2.61… \"2.63… 1 2 #> 3 d3_1 Median \"3.7300\" \"2.70… \"2.77… 1 3 #> 4 d4_1 Q1, Q3 \"3.4500, 3.9575\" \"2.13… \"2.14… 1 4 #> 5 d5_1 Min, Max \"2.465, 5.424\" \"1.61… \"1.51… 1 5 #> 6 d6_1 Missing \" 0\" \" 0\" \" 0\" 1 6 get_metadata(t) #> # A tibble: 6 × 5 #> row_id row_label1 var1_3 var1_4 var1_5 #> #> 1 d1_1 n #> 2 d2_1 Mean (SD) #> 3 d3_1 Median #> 4 d4_1 Q1, Q3 #> 5 d5_1 Min, Max #> 6 d6_1 Missing "},{"path":"https://atorus-research.github.io/Tplyr/reference/get_numeric_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Retrieve the numeric data from a tplyr objects — get_numeric_data","title":"Retrieve the numeric data from a tplyr objects — get_numeric_data","text":"get_numeric_data provides access un-formatted numeric data layers within tplyr_table, options allow extract distinct layers filter desired.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_numeric_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Retrieve the numeric data from a tplyr objects — get_numeric_data","text":"","code":"get_numeric_data(x, layer = NULL, where = TRUE, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_numeric_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Retrieve the numeric data from a tplyr objects — get_numeric_data","text":"x tplyr_table tplyr_layer object layer Layer name index select specifically Subset criteria passed dplyr::filter ... Additional arguments pass forward","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_numeric_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Retrieve the numeric data from a tplyr objects — get_numeric_data","text":"Numeric data Tplyr layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_numeric_data.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Retrieve the numeric data from a tplyr objects — get_numeric_data","text":"used tplyr_table object, method aggregate numeric data Tplyr layers. data returned user list data frames. data already processed (.e. build run), numeric data already available returned without reprocessing. Otherwise, numeric portion layer processed. Using layer parameters, data specific layer can extracted subset. clear layers given text names instead using layer index, numeric index works well.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_numeric_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Retrieve the numeric data from a tplyr objects — get_numeric_data","text":"","code":"# Load in pipe library(magrittr) t <- tplyr_table(mtcars, gear) %>% add_layer(name='drat', group_desc(drat) ) %>% add_layer(name='cyl', group_count(cyl) ) # Return a list of the numeric data frames get_numeric_data(t) #> $drat #> # A tibble: 27 × 4 #> summary_var gear stat value #> #> 1 drat 3 n 15 #> 2 drat 3 mean 3.13 #> 3 drat 3 sd 0.274 #> 4 drat 3 median 3.08 #> 5 drat 3 q1 3.04 #> 6 drat 3 q3 3.18 #> 7 drat 3 min 2.76 #> 8 drat 3 max 3.73 #> 9 drat 3 missing 0 #> 10 drat 4 n 12 #> # ℹ 17 more rows #> #> $cyl #> # A tibble: 9 × 6 #> gear summary_var n distinct_n total distinct_total #> #> 1 3 4 1 1 15 1 #> 2 3 6 2 1 15 1 #> 3 3 8 12 1 15 1 #> 4 4 4 8 1 12 1 #> 5 4 6 4 1 12 1 #> 6 4 8 0 0 12 1 #> 7 5 4 2 1 5 1 #> 8 5 6 1 1 5 1 #> 9 5 8 2 1 5 1 #> # Get the data from a specific layer get_numeric_data(t, layer='drat') #> # A tibble: 27 × 4 #> summary_var gear stat value #> #> 1 drat 3 n 15 #> 2 drat 3 mean 3.13 #> 3 drat 3 sd 0.274 #> 4 drat 3 median 3.08 #> 5 drat 3 q1 3.04 #> 6 drat 3 q3 3.18 #> 7 drat 3 min 2.76 #> 8 drat 3 max 3.73 #> 9 drat 3 missing 0 #> 10 drat 4 n 12 #> # ℹ 17 more rows get_numeric_data(t, layer=1) #> # A tibble: 27 × 4 #> summary_var gear stat value #> #> 1 drat 3 n 15 #> 2 drat 3 mean 3.13 #> 3 drat 3 sd 0.274 #> 4 drat 3 median 3.08 #> 5 drat 3 q1 3.04 #> 6 drat 3 q3 3.18 #> 7 drat 3 min 2.76 #> 8 drat 3 max 3.73 #> 9 drat 3 missing 0 #> 10 drat 4 n 12 #> # ℹ 17 more rows # Choose multiple layers by name or index get_numeric_data(t, layer=c('cyl', 'drat')) #> $cyl #> # A tibble: 9 × 6 #> gear summary_var n distinct_n total distinct_total #> #> 1 3 4 1 1 15 1 #> 2 3 6 2 1 15 1 #> 3 3 8 12 1 15 1 #> 4 4 4 8 1 12 1 #> 5 4 6 4 1 12 1 #> 6 4 8 0 0 12 1 #> 7 5 4 2 1 5 1 #> 8 5 6 1 1 5 1 #> 9 5 8 2 1 5 1 #> #> $drat #> # A tibble: 27 × 4 #> summary_var gear stat value #> #> 1 drat 3 n 15 #> 2 drat 3 mean 3.13 #> 3 drat 3 sd 0.274 #> 4 drat 3 median 3.08 #> 5 drat 3 q1 3.04 #> 6 drat 3 q3 3.18 #> 7 drat 3 min 2.76 #> 8 drat 3 max 3.73 #> 9 drat 3 missing 0 #> 10 drat 4 n 12 #> # ℹ 17 more rows #> get_numeric_data(t, layer=c(2, 1)) #> $cyl #> # A tibble: 9 × 6 #> gear summary_var n distinct_n total distinct_total #> #> 1 3 4 1 1 15 1 #> 2 3 6 2 1 15 1 #> 3 3 8 12 1 15 1 #> 4 4 4 8 1 12 1 #> 5 4 6 4 1 12 1 #> 6 4 8 0 0 12 1 #> 7 5 4 2 1 5 1 #> 8 5 6 1 1 5 1 #> 9 5 8 2 1 5 1 #> #> $drat #> # A tibble: 27 × 4 #> summary_var gear stat value #> #> 1 drat 3 n 15 #> 2 drat 3 mean 3.13 #> 3 drat 3 sd 0.274 #> 4 drat 3 median 3.08 #> 5 drat 3 q1 3.04 #> 6 drat 3 q3 3.18 #> 7 drat 3 min 2.76 #> 8 drat 3 max 3.73 #> 9 drat 3 missing 0 #> 10 drat 4 n 12 #> # ℹ 17 more rows #> # Get the data and filter it get_numeric_data(t, layer='drat', where = gear==3) #> # A tibble: 9 × 4 #> summary_var gear stat value #> #> 1 drat 3 n 15 #> 2 drat 3 mean 3.13 #> 3 drat 3 sd 0.274 #> 4 drat 3 median 3.08 #> 5 drat 3 q1 3.04 #> 6 drat 3 q3 3.18 #> 7 drat 3 min 2.76 #> 8 drat 3 max 3.73 #> 9 drat 3 missing 0"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_stats_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Get statistics data — get_stats_data","title":"Get statistics data — get_stats_data","text":"Like layer numeric data, Tplyr also stores numeric data produced statistics like risk difference. helper function gives access obtain data environment","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_stats_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get statistics data — get_stats_data","text":"","code":"get_stats_data(x, layer = NULL, statistic = NULL, where = TRUE, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_stats_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get statistics data — get_stats_data","text":"x tplyr_table tplyr_layer object layer Layer name index select specifically statistic Statistic name index select Subset criteria passed dplyr::filter ... Additional arguments passed dispatch","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_stats_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get statistics data — get_stats_data","text":"statistics data supplied layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_stats_data.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Get statistics data — get_stats_data","text":"used tplyr_table object, method aggregate numeric data Tplyr layers calculate statistics. data returned user list data frames. data already processed (.e. build run), numeric data already available statistic data simply returned. Otherwise, numeric portion layer processed. Using layer, , statistic parameters, data specific layer statistic can extracted subset, allowing directly access data interest. clear layers given text names instead using layer index, numeric index works well. just statistic specified, statistic collected returned list data frames, allowing grab, example, just risk difference statistics across layers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_stats_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get statistics data — get_stats_data","text":"","code":"library(magrittr) t <- tplyr_table(mtcars, gear) %>% add_layer(name='drat', group_desc(drat) ) %>% add_layer(name=\"cyl\", group_count(cyl) ) %>% add_layer(name=\"am\", group_count(am) %>% add_risk_diff(c('4', '3')) ) %>% add_layer(name=\"carb\", group_count(carb) %>% add_risk_diff(c('4', '3')) ) # Returns a list of lists, containing stats data from each layer get_stats_data(t) #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> Warning: Chi-squared approximation may be incorrect #> $drat #> list() #> #> $cyl #> list() #> #> $am #> $am$riskdiff #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> #> #> $carb #> $carb$riskdiff #> # A tibble: 30 × 3 #> summary_var measure `4_3` #> #> 1 1 comp 0.333 #> 2 1 ref 0.2 #> 3 1 dif 0.133 #> 4 1 low -0.277 #> 5 1 high 0.543 #> 6 2 comp 0.333 #> 7 2 ref 0.267 #> 8 2 dif 0.0667 #> 9 2 low -0.348 #> 10 2 high 0.481 #> # ℹ 20 more rows #> #> # Returns just the riskdiff statistics from each layer - NULL # for layers without riskdiff get_stats_data(t, statistic=\"riskdiff\") #> $drat #> NULL #> #> $cyl #> NULL #> #> $am #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> #> $carb #> # A tibble: 30 × 3 #> summary_var measure `4_3` #> #> 1 1 comp 0.333 #> 2 1 ref 0.2 #> 3 1 dif 0.133 #> 4 1 low -0.277 #> 5 1 high 0.543 #> 6 2 comp 0.333 #> 7 2 ref 0.267 #> 8 2 dif 0.0667 #> 9 2 low -0.348 #> 10 2 high 0.481 #> # ℹ 20 more rows #> # Return the statistic data for just the \"am\" layer - a list get_stats_data(t, layer=\"am\") #> $riskdiff #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> get_stats_data(t, layer=3) #> $riskdiff #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> # Return the statistic data for just the \"am\" and \"cyl\", layer - a # list of lists get_stats_data(t, layer=c(\"am\", \"cyl\")) #> $am #> $am$riskdiff #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> #> #> $cyl #> list() #> get_stats_data(t, layer=c(3, 2)) #> $am #> $am$riskdiff #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> #> #> $cyl #> list() #> # Return just the statistic data for \"am\" and \"cyl\" - a list get_stats_data(t, layer=c(\"am\", \"cyl\"), statistic=\"riskdiff\") #> $am #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> #> $cyl #> NULL #> get_stats_data(t, layer=c(3, 2), statistic=\"riskdiff\") #> $am #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 #> #> $cyl #> NULL #> # Return the riskdiff for the \"am\" layer - a data frame get_stats_data(t, layer=\"am\", statistic=\"riskdiff\") #> # A tibble: 10 × 3 #> summary_var measure `4_3` #> #> 1 0 comp 0.333 #> 2 0 ref 1 #> 3 0 dif -0.667 #> 4 0 low -1 #> 5 0 high -0.325 #> 6 1 comp 0.667 #> 7 1 ref 0 #> 8 1 dif 0.667 #> 9 1 low 0.325 #> 10 1 high 1 # Return and filter the riskdiff for the am layer - a data frame get_stats_data(t, layer=\"am\", statistic=\"riskdiff\", where = summary_var==1) #> # A tibble: 5 × 3 #> summary_var measure `4_3` #> #> 1 1 comp 0.667 #> 2 1 ref 0 #> 3 1 dif 0.667 #> 4 1 low 0.325 #> 5 1 high 1"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_tplyr_regex.html","id":null,"dir":"Reference","previous_headings":"","what":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","title":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","text":"function allows extract important regular expressions used inside Tplyr.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_tplyr_regex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","text":"","code":"get_tplyr_regex(rx = c(\"format_string\", \"format_group\"))"},{"path":"https://atorus-research.github.io/Tplyr/reference/get_tplyr_regex.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","text":"rx character string either value 'format_string' 'format_group'","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_tplyr_regex.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","text":"regular expression object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_tplyr_regex.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","text":"two important regular expressions used within Tplyr. format_string expression expression parse format strings. used make sense strings like 'xx (XX.x%)' '+1 (.+2)' inferring user specifying number formatting. 'format_group' regex opposite , given string numbers, ' 5 (34%) [9]' return separate segments numbers broken format groups, example ' 5', '(34%)', '[9]'.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/get_tplyr_regex.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Retrieve one of Tplyr's regular expressions — get_tplyr_regex","text":"","code":"get_tplyr_regex('format_string') #> [1] \"(a(\\\\+\\\\d+)?|(\\\\S+)A(\\\\+\\\\d+)?|(\\\\S+)X+|x+)(\\\\.([A|a](\\\\+\\\\d+)?|[X|x]+)?)?\" #> attr(,\"options\") #> attr(,\"options\")$case_insensitive #> [1] FALSE #> #> attr(,\"options\")$comments #> [1] FALSE #> #> attr(,\"options\")$dotall #> [1] FALSE #> #> attr(,\"options\")$multiline #> [1] FALSE #> #> attr(,\"class\") #> [1] \"stringr_regex\" \"stringr_pattern\" \"character\" get_tplyr_regex('format_group') #> [1] \"[^\\\\s\\\\d]*\\\\s*(\\\\-?\\\\d+(\\\\.\\\\d+)?)\\\\S*\" #> attr(,\"options\") #> attr(,\"options\")$case_insensitive #> [1] FALSE #> #> attr(,\"options\")$comments #> [1] FALSE #> #> attr(,\"options\")$dotall #> [1] FALSE #> #> attr(,\"options\")$multiline #> [1] FALSE #> #> attr(,\"class\") #> [1] \"stringr_regex\" \"stringr_pattern\" \"character\""},{"path":"https://atorus-research.github.io/Tplyr/reference/header_n.html","id":null,"dir":"Reference","previous_headings":"","what":"Return or set header_n binding — header_n","title":"Return or set header_n binding — header_n","text":"`header_n()` functions can used automatically pull header_n derivations table change future use.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/header_n.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return or set header_n binding — header_n","text":"","code":"header_n(table) header_n(x) <- value set_header_n(table, value)"},{"path":"https://atorus-research.github.io/Tplyr/reference/header_n.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return or set header_n binding — header_n","text":"table tplyr_table object x tplyr_table object value data.frame columns treatment variable, column variabes, variable counts named 'n'. header_n data.frame columns treatment variable, column variabes, variable counts named 'n'.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/header_n.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return or set header_n binding — header_n","text":"tplyr_header_n header_n binding tplyr_table object. tplyr_header_n<- set_tplyr_header_n modified object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/header_n.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Return or set header_n binding — header_n","text":"`header_n` object created Tplyr table built intended used `add_column_headers()` function displaying table level population totals. methods intended used calling population totals calculated Tplyr, overwrite user chooses . need change header Ns appear table headers, say know working subset data represent totals, can replace data used `set_header_n()`.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/header_n.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return or set header_n binding — header_n","text":"","code":"tab <- tplyr_table(mtcars, gear) header_n(tab) <- data.frame( gear = c(3, 4, 5), n = c(10, 15, 45) )"},{"path":"https://atorus-research.github.io/Tplyr/reference/keep_levels.html","id":null,"dir":"Reference","previous_headings":"","what":"Select levels to keep in a count layer — keep_levels","title":"Select levels to keep in a count layer — keep_levels","text":"certain cases want layer include certain values factor. `keep_levels()` function allows pass character values included layer. others ignored. **NOTE: Denominator calculation unaffected function, see examples include logic percentages'**","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/keep_levels.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Select levels to keep in a count layer — keep_levels","text":"","code":"keep_levels(e, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/keep_levels.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Select levels to keep in a count layer — keep_levels","text":"e count_layer object ... Character values count int layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/keep_levels.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Select levels to keep in a count layer — keep_levels","text":"modified Tplyr layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/keep_levels.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Select levels to keep in a count layer — keep_levels","text":"","code":"library(dplyr) mtcars <- mtcars %>% mutate_all(as.character) t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% keep_levels(\"4\", \"8\") %>% set_denom_where(cyl %in% c(\"4\", \"8\")) ) %>% build()"},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_attachment.html","id":null,"dir":"Reference","previous_headings":"","what":"Attach a layer to a tplyr_table object — add_layer","title":"Attach a layer to a tplyr_table object — add_layer","text":"add_layer attaches tplyr_layer tplyr_table object. allows tidy style programming (using magrittr piping, .e. %>%) secondary advantage - construction layer object may consist series piped functions . Tplyr encourages user view construction table series \"layers\". construction layers isolated independent one another - layers children table . add_layer isolates construction individual layer allows user construct layer insert back parent. syntax intuitive allows tidy piping. Simply pipe current table object , write code construct layer within layer parameter. add_layers another approach attaching layers tplyr_table. Instead constructing entire table , add_layers allows construct layers different objects. layers can attached tplyr_table . add_layer add_layers additionally allow name layers attach . helpful using functions like get_numeric_data get_stats_data can access information layer directly. add_layer name parameter, layers can named add_layers submitting layer named argument.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_attachment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Attach a layer to a tplyr_table object — add_layer","text":"","code":"add_layer(parent, layer, name = NULL) add_layers(parent, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_attachment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Attach a layer to a tplyr_table object — add_layer","text":"parent tplyr_table tplyr_layer/tplyr_subgroup_layer object layer layer construction function associated modifier functions name name provide layer table layers container ... Layers added","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_attachment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Attach a layer to a tplyr_table object — add_layer","text":"tplyr_table tplyr_layer/tplyr_subgroup_layer new layer inserted layer binding","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_attachment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Attach a layer to a tplyr_table object — add_layer","text":"","code":"# Load in pipe library(magrittr) ## Single layer t <- tplyr_table(mtcars, cyl) %>% add_layer( group_desc(target_var=mpg) ) ## Single layer with name t <- tplyr_table(mtcars, cyl) %>% add_layer(name='mpg', group_desc(target_var=mpg) ) # Using add_layers t <- tplyr_table(mtcars, cyl) l1 <- group_desc(t, target_var=mpg) l2 <- group_count(t, target_var=cyl) t <- add_layers(t, l1, 'cyl' = l2)"},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_constructors.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","title":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","text":"family functions specifies type summary performed within layer. count layers used create summary counts discrete variable. desc layers create summary statistics, shift layers summaries counts different changes states. See \"details\" section information.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_constructors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","text":"","code":"group_count(parent, target_var, by = vars(), where = TRUE, ...) group_desc(parent, target_var, by = vars(), where = TRUE, ...) group_shift(parent, target_var, by = vars(), where = TRUE, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_constructors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","text":"parent Required. parent environment layer. must tplyr_table object layer contained within. target_var Symbol. Required, variable name(s) summary performed. Must variable within target dataset. Enter unquoted - .e. target_var = AEBODSYS. may also provide multiple variables vars. string, variable name, list variable names supplied using vars Call. Filter logic used subset target data performing summary. ... Additional arguments pass forward","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_constructors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","text":"tplyr_layer environment child specified parent. environment contains object listed . tplyr_layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_constructors.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","text":"Count Layers Count layers allow create summaries based counting values variable. Additionally, layer allows create n (%) summaries also summarizing proportion instances value occurs compared denominator. Count layers also capable producing counts nested relationships. example, want produce counts overall outside group, subgroup counts within group, can specify target variable vars(OutsideVariable, InsideVariable). allows tables like Adverse Events want see Preferred Terms within Body Systems, one layer. control denominators available using function set_denoms_by distinct counts can set using set_distinct_by Descriptive Statistics Layers Descriptive statistics layers perform summaries continuous variables. number summaries built Tplyr already can perform, including n, mean, median, standard deviation, variance, min, max, inter-quartile range, Q1, Q3, missing value counts. available summaries, default presentation descriptive statistic layer output 'n', 'Mean (SD)', 'Median', 'Q1, Q3', 'Min, Max', 'Missing'. can change summaries using set_format_strings, can also add summaries using set_custom_summaries. allows implement additional summary statistics want presented. Shift Layers shift layer displays endpoint's 'shift' throughout duration study. abstraction count layer, however provided interface efficient intuitive. Targets passed named symbols using dplyr::vars. Generally baseline passed name 'row' shift passed name 'column'. counts (n) percentages (pct) supported can specified set_format_strings function. allow flexibility defining percentages, can define denominator using set_denoms_by function. function takes variable names uses determine denominator counts.","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_constructors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a count, desc, or shift layer for discrete count\nbased summaries, descriptive statistics summaries, or shift count summaries — group_count","text":"","code":"# Load in pipe library(magrittr) t <- tplyr_table(iris, Species) %>% add_layer( group_desc(target_var=Sepal.Width) ) t <- tplyr_table(iris, Species) %>% add_layer( group_desc(target_var=Sepal.Width) ) t <- tplyr_table(mtcars, am) %>% add_layer( group_shift(vars(row=gear, column=carb), by=cyl) )"},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_templates.html","id":null,"dir":"Reference","previous_headings":"","what":"Create, view, extract, remove, and use Tplyr layer templates — new_layer_template","title":"Create, view, extract, remove, and use Tplyr layer templates — new_layer_template","text":"several scenarios layer template may useful. tables, like demographics tables, may many layers essentially look . Categorical variables count layer settings, continuous variables desc layer settings. template allows user build settings per layer, reference template Tplyr table actually built.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_templates.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create, view, extract, remove, and use Tplyr layer templates — new_layer_template","text":"","code":"new_layer_template(name, template) remove_layer_template(name) get_layer_template(name) get_layer_templates() use_template(name, ..., add_params = NULL)"},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_templates.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create, view, extract, remove, and use Tplyr layer templates — new_layer_template","text":"name Template name template Template layer syntax, starting layer constructor group_count|desc|shift. function called ellipsis argument (.e. group_count(...)). ... Arguments passed directly layer constructor, matching target, , parameters. add_params Additional parameters passed layer modifier functions. arguments specified template within curly brackets {param}. Supply named list, element name parameter.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_templates.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create, view, extract, remove, and use Tplyr layer templates — new_layer_template","text":"suite functions allows user create use layer templates. Layer templates allow user pre-build reuse entire layer configuration, layer constructor modifying functions. Furthermore, users can specify parameters may want interchangeable. Additionally, layer templates extensible, template can use extended additional layer modifying functions. Layers created using new_layer_template(). use layer, use function use_template() place group_count|desc|shift(). want view specific template, use get_layer_template(). want view templates, use get_layer_templates(). remove layer template use remove_layer_template(). Layer templates stored option tplyr.layer_templates, user access directly instead use Tplyr supplied functions. providing template layer syntax, layer must start layer constructor. one function group_count(), group_desc(), group_shift(). Instead passing arguments function, templates specified using ellipsis constructor, .e. group_count(...). required, template built user supplies arguments via use_template() use_template() takes group_count|desc|shift() arguments default. user specified additional arguments template, provided list throught argument add_params. Provide arguments exactly normal layer. creating template, parameters can specified using curly brackets. See examples details.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/layer_templates.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create, view, extract, remove, and use Tplyr layer templates — new_layer_template","text":"","code":"op <- options() new_layer_template( \"example_template\", group_count(...) %>% set_format_strings(f_str('xx (xx%)', n, pct)) ) get_layer_templates() #> $example_template #> Template name: example_template #> Template parameters: None #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx%)\", n, pct)) #> } #> get_layer_template(\"example_template\") #> Template name: example_template #> Template parameters: None #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx%)\", n, pct)) #> } tplyr_table(mtcars, vs) %>% add_layer( use_template(\"example_template\", gear) ) %>% build() #> # A tibble: 3 × 5 #> row_label1 var1_0 var1_1 ord_layer_index ord_layer_1 #> #> 1 3 \"12 (67%)\" \" 3 (21%)\" 1 1 #> 2 4 \" 2 (11%)\" \"10 (71%)\" 1 2 #> 3 5 \" 4 (22%)\" \" 1 ( 7%)\" 1 3 remove_layer_template(\"example_template\") new_layer_template( \"example_template\", group_count(...) %>% set_format_strings(f_str('xx (xx%)', n, pct)) %>% set_order_count_method({sort_meth}) %>% set_ordering_cols({sort_cols}) ) get_layer_template(\"example_template\") #> Template name: example_template #> Template parameters: sort_meth, sort_cols #> Template code: #> { #> group_count(...) %>% set_format_strings(f_str(\"xx (xx%)\", n, pct)) %>% set_order_count_method({ #> sort_meth #> }) %>% set_ordering_cols({ #> sort_cols #> }) #> } tplyr_table(mtcars, vs) %>% add_layer( use_template(\"example_template\", gear, add_params = list( sort_meth = \"bycount\", sort_cols = `1` )) ) %>% build() #> # A tibble: 3 × 5 #> row_label1 var1_0 var1_1 ord_layer_index ord_layer_1 #> #> 1 3 \"12 (67%)\" \" 3 (21%)\" 1 3 #> 2 4 \" 2 (11%)\" \"10 (71%)\" 1 10 #> 3 5 \" 4 (22%)\" \" 1 ( 7%)\" 1 1 remove_layer_template(\"example_template\") options(op)"},{"path":"https://atorus-research.github.io/Tplyr/reference/metadata_additions.html","id":null,"dir":"Reference","previous_headings":"","what":"Add variables to a tplyr_meta object — add_variables","title":"Add variables to a tplyr_meta object — add_variables","text":"Add additional variable names tplyr_meta() object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/metadata_additions.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add variables to a tplyr_meta object — add_variables","text":"","code":"add_variables(meta, names) add_filters(meta, filters)"},{"path":"https://atorus-research.github.io/Tplyr/reference/metadata_additions.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add variables to a tplyr_meta object — add_variables","text":"meta tplyr_meta object names list names, providing variable names interest. Provide list quosures using rlang::quos() filters list symbols, providing variable names interest. Provide list quosures using `rlang::quos()`","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/metadata_additions.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add variables to a tplyr_meta object — add_variables","text":"tplyr_meta object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/metadata_additions.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add variables to a tplyr_meta object — add_variables","text":"","code":"m <- tplyr_meta() m <- add_variables(m, rlang::quos(a, b, c)) m <- add_filters(m, rlang::quos(a==1, b==2, c==3)) m #> tplyr_meta: 3 names, 3 filters #> Names: #> a, b, c #> Filters: #> a == 1, b == 2, c == 3"},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the ordering logic for the count layer — set_order_count_method","title":"Set the ordering logic for the count layer — set_order_count_method","text":"sorting table can greatly vary depending situation hand. count layers, creating tables like adverse event summaries, may wish order table descending occurrence within particular treatment group. situations, AEs special interest, subject disposition, may specific order wish display values. Tplyr offers solutions situations. Instead allowing specify custom sort order, Tplyr instead provides order variables can used sort table data summarized. Tplyr default order table returned, order variables always persist. allows use powerful sorting functions like arrange get desired order, double programming situations, helps validator understand achieved particular sort order discrepancies may coming . creating order variables layer, '' variable Tplyr search N version variable (.e. VISIT <-> VISITN, PARAM <-> PARAMN). available, variable used sorting. available, Tplyr created new ordered factor version variable use alphanumeric sorting. allows user control custom sorting order leaving existing N variable dataset exists, create one based order wish sort - custom functions Tplyr required. Ordering results things start differ. Different situations call different methods. Descriptive statistics layers keep simple - order input formats using set_format_strings order results appear (order variable added). count layers, Tplyr offers three solutions: N version target variable, use . , target variable factor, use factor orders. Finally, can use specific data point results columns. result column can often multiple data points, n counts, percent, distinct n, distinct percent. Tplyr allows choose values used creating order columns specified result column (.e. based treat_var cols arguments). See 'Sorting Table' section information. Shift layers sort similarly count layers, order row shift variable, use ordered factor.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the ordering logic for the count layer — set_order_count_method","text":"","code":"set_order_count_method(e, order_count_method, break_ties = NULL) set_ordering_cols(e, ...) set_result_order_var(e, result_order_var)"},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the ordering logic for the count layer — set_order_count_method","text":"e count_layer object order_count_method logic determining rows final layer output indexed. Options 'bycount', 'byfactor', 'byvarn'. break_ties certain cases, 'bycount' sort result conflicts counts unique. break_ties add decimal sorting column resolve conflicts. character value 'asc' add decimal based alphabetical sorting. 'desc' sort descending case intention. ... Unquoted variables used select columns whose values extracted ordering. result_order_var numeric value ordering done . can either n, distinct_n, pct, distinct_pct. Due evaluation layer can add value actually evaluated, happens error ordering.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the ordering logic for the count layer — set_order_count_method","text":"Returns modified layer object. 'ord_' columns added build process.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"sorting-a-table","dir":"Reference","previous_headings":"","what":"Sorting a Table","title":"Set the ordering logic for the count layer — set_order_count_method","text":"table built, output several ordering(ord_) columns appended. first represents layer index. index determined order layer added table. Following indices variables target variable. variables ordered based : `` variable factor target dataset variable factor, N variable (.e. VISIT -> VISITN, TRT -> TRTN) variable factor target dataset, coerced one ordered alphabetically. target variable ordered depending type layer. See .","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"ordering-a-count-layer","dir":"Reference","previous_headings":"","what":"Ordering a Count Layer","title":"Set the ordering logic for the count layer — set_order_count_method","text":"many ways order count layer depending preferences table programmer. Tplyr supports sorting descending amount column table, sorting N variable, sorting custom order. can set using `set_order_count_method` function. Sorting numeric count selected numeric value selected column indexed based descending numeric value. numeric value extracted defaults 'n' can changed `set_result_order_var`. column selected sorting defaults first value treatment group variable. arguments passed 'cols' argument table must specified `set_ordering_columns`. Sorting 'varn' variable treatment variable N variable. can indexed variable. Sorting factor(Default) factor found target variable target dataset used order, factor found coerced factor sorted alphabetically. Sorting nested count layer two variables targeted count layer, two methods can passed `set_order_count`. two passed, first used sort blocks, second used sort \"inside\" blocks. one method passed, used sort .","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"ordering-a-desc-layer","dir":"Reference","previous_headings":"","what":"Ordering a Desc Layer","title":"Set the ordering logic for the count layer — set_order_count_method","text":"order desc layer mostly set object construction. variables resolved index logic count layers. target variable ordered based format strings used layer created.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/ordering.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the ordering logic for the count layer — set_order_count_method","text":"","code":"library(dplyr) # Default sorting by factor t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) ) build(t) #> # A tibble: 3 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 6 \" 2 ( 13.3%)\" \" 4 ( 33.3%)\" \" 1 ( 20.0… 1 2 #> 3 8 \"12 ( 80.0%)\" \" 0 ( 0.0%)\" \" 2 ( 40.0… 1 3 # Sorting by N mtcars$cylN <- mtcars$cyl t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% set_order_count_method(\"byvarn\") ) # Sorting by row count t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% set_order_count_method(\"bycount\") %>% # Orders based on the 6 gear group set_ordering_cols(6) ) # Sorting by row count by percentages t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% set_order_count_method(\"bycount\") %>% set_result_order_var(pct) ) # Sorting when you have column arguments in the table t <- tplyr_table(mtcars, gear, cols = vs) %>% add_layer( group_count(cyl) %>% # Uses the fourth gear group and the 0 vs group in ordering set_ordering_cols(4, 0) ) # Using a custom factor to order mtcars$cyl <- factor(mtcars$cyl, c(6, 4, 8)) t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% # This is the default but can be used to change the setting if it is #set at the table level. set_order_count_method(\"byfactor\") )"},{"path":"https://atorus-research.github.io/Tplyr/reference/pipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Pipe operator — %>%","title":"Pipe operator — %>%","text":"See magrittr::%>% details.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pipe operator — %>%","text":"","code":"lhs %>% rhs"},{"path":"https://atorus-research.github.io/Tplyr/reference/pipe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Pipe operator — %>%","text":"lhs value magrittr placeholder. rhs function call using magrittr semantics.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pipe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Pipe operator — %>%","text":"result calling `rhs(lhs)`.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Return or set population data bindings — pop_data","title":"Return or set population data bindings — pop_data","text":"population data used gather information may available target dataset. example, missing treatment groups, population N counts, proper N counts denominators provided population dataset. population dataset defaults target dataset unless otherwise specified using set_pop_data.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return or set population data bindings — pop_data","text":"","code":"pop_data(table) pop_data(x) <- value set_pop_data(table, pop_data)"},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return or set population data bindings — pop_data","text":"table tplyr_table object x tplyr_table object value data.frame population level information pop_data data.frame population level information","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return or set population data bindings — pop_data","text":"tplyr_pop_data pop_data binding tplyr_table object. tplyr_pop_data<- nothing returned, pop_data binding set silently. set_tplyr_pop_data modified object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return or set population data bindings — pop_data","text":"","code":"tab <- tplyr_table(iris, Species) pop_data(tab) <- mtcars tab <- tplyr_table(iris, Species) %>% set_pop_data(mtcars)"},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_treat_var.html","id":null,"dir":"Reference","previous_headings":"","what":"Return or set pop_treat_var binding — pop_treat_var","title":"Return or set pop_treat_var binding — pop_treat_var","text":"treatment variable used target data may different variable within population dataset. set_pop_treat_var allows change .","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_treat_var.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return or set pop_treat_var binding — pop_treat_var","text":"","code":"pop_treat_var(table) set_pop_treat_var(table, pop_treat_var)"},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_treat_var.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return or set pop_treat_var binding — pop_treat_var","text":"table tplyr_table object pop_treat_var Variable containing treatment group assignments within pop_data binding. Supply unquoted.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_treat_var.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return or set pop_treat_var binding — pop_treat_var","text":"tplyr_pop_treat_var pop_treat_var binding tplyr_table object. set_tplyr_pop_treat_var modified object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/pop_treat_var.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return or set pop_treat_var binding — pop_treat_var","text":"","code":"tab <- tplyr_table(iris, Species) pop_data(tab) <- mtcars set_pop_treat_var(tab, mpg) #> *** tplyr_table *** #> Target (data.frame): #> \tName: iris #> \tRows: 150 #> \tColumns: 5 #> pop_data (data.frame) #> \tName: value #> \tRows: 32 #> \tColumns: 11 #> treat_var variable (quosure) #> \tSpeciespop_treat_var variable (quosure) #> \tmpg #> #> header_n: header groups #> treat_grps groupings (list) #> Table Columns (cols): #> where: TRUE #> Number of layer(s): 0 #> layer_output: 0"},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_by.html","id":null,"dir":"Reference","previous_headings":"","what":"Set or return precision_by layer binding — get_precision_by","title":"Set or return precision_by layer binding — get_precision_by","text":"precision_by variables used collect integer decimal precision auto-precision used. variables used group input data identify maximum precision available within dataset group. precision_by variables must subset variables","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_by.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set or return precision_by layer binding — get_precision_by","text":"","code":"get_precision_by(layer) set_precision_by(layer, precision_by)"},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_by.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set or return precision_by layer binding — get_precision_by","text":"layer tplyr_layer object precision_by string, variable name, list variable names supplied using dplyr::vars.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_by.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set or return precision_by layer binding — get_precision_by","text":"get_precision_by, precision_by binding supplied layer. set_precision_by modified layer environment.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_by.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set or return precision_by layer binding — get_precision_by","text":"","code":"# Load in pipe library(magrittr) lay <- tplyr_table(mtcars, gear) %>% add_layer( group_desc(mpg, by=vars(carb, am)) %>% set_precision_by(carb) )"},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_on.html","id":null,"dir":"Reference","previous_headings":"","what":"Set or return precision_on layer binding — get_precision_on","title":"Set or return precision_on layer binding — get_precision_on","text":"precision_on variable variable used establish numeric precision. variable must included list target_var variables.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_on.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set or return precision_on layer binding — get_precision_on","text":"","code":"get_precision_on(layer) set_precision_on(layer, precision_on)"},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_on.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set or return precision_on layer binding — get_precision_on","text":"layer tplyr_layer object precision_on string, variable name, list variable names supplied using dplyr::vars.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_on.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set or return precision_on layer binding — get_precision_on","text":"get_precision_on, precision_on binding supplied layer. set_precision_on modified layer environment.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/precision_on.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set or return precision_on layer binding — get_precision_on","text":"","code":"# Load in pipe library(magrittr) lay <- tplyr_table(mtcars, gear) %>% add_layer( group_desc(vars(mpg, disp), by=vars(carb, am)) %>% set_precision_on(disp) )"},{"path":"https://atorus-research.github.io/Tplyr/reference/process_formatting.html","id":null,"dir":"Reference","previous_headings":"","what":"Process layers to get formatted and pivoted tables. — process_formatting","title":"Process layers to get formatted and pivoted tables. — process_formatting","text":"internal method, exported support S3 dispatch. intended direct use user.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_formatting.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process layers to get formatted and pivoted tables. — process_formatting","text":"","code":"process_formatting(x, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/process_formatting.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process layers to get formatted and pivoted tables. — process_formatting","text":"x tplyr_layer object ... arguments passed dispatch","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_formatting.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process layers to get formatted and pivoted tables. — process_formatting","text":"formatted_table object bound layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_metadata.html","id":null,"dir":"Reference","previous_headings":"","what":"Process layers to get metadata tables — process_metadata","title":"Process layers to get metadata tables — process_metadata","text":"internal method, exported support S3 dispatch. intended direct use user.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_metadata.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process layers to get metadata tables — process_metadata","text":"","code":"process_metadata(x, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/process_metadata.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process layers to get metadata tables — process_metadata","text":"x tplyr_layer object ... arguments passed dispatch","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_metadata.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process layers to get metadata tables — process_metadata","text":"formatted_meta object bound layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Process a tplyr_statistic object — process_statistic_data","title":"Process a tplyr_statistic object — process_statistic_data","text":"internal function meant use externally, must exported. Use caution.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process a tplyr_statistic object — process_statistic_data","text":"","code":"process_statistic_data(x, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process a tplyr_statistic object — process_statistic_data","text":"x tplyr_statistic environment ... Additional pass parameters","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_data.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process a tplyr_statistic object — process_statistic_data","text":"Numeric statistc data tplyr statistc","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_formatting.html","id":null,"dir":"Reference","previous_headings":"","what":"Process string formatting on a tplyr_statistic object — process_statistic_formatting","title":"Process string formatting on a tplyr_statistic object — process_statistic_formatting","text":"internal function meant use externally, must exported. Use caution.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_formatting.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process string formatting on a tplyr_statistic object — process_statistic_formatting","text":"","code":"process_statistic_formatting(x, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_formatting.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process string formatting on a tplyr_statistic object — process_statistic_formatting","text":"x tplyr_statistic environment ... Additional pass parameters","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_statistic_formatting.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process string formatting on a tplyr_statistic object — process_statistic_formatting","text":"Formatted tplyr_statistic data","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_summaries.html","id":null,"dir":"Reference","previous_headings":"","what":"Process layers to get numeric results of layer — process_summaries","title":"Process layers to get numeric results of layer — process_summaries","text":"internal method, exported support S3 dispatch. intended direct use user.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_summaries.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Process layers to get numeric results of layer — process_summaries","text":"","code":"process_summaries(x, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/process_summaries.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Process layers to get numeric results of layer — process_summaries","text":"x tplyr_layer object ... arguments passed dispatch","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/process_summaries.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Process layers to get numeric results of layer — process_summaries","text":"tplyr_layer object 'built_table' binding","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/replace_leading_whitespace.html","id":null,"dir":"Reference","previous_headings":"","what":"Reformat strings with leading whitespace for HTML — replace_leading_whitespace","title":"Reformat strings with leading whitespace for HTML — replace_leading_whitespace","text":"Reformat strings leading whitespace HTML","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/replace_leading_whitespace.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reformat strings with leading whitespace for HTML — replace_leading_whitespace","text":"","code":"replace_leading_whitespace(x, tab_width = 4)"},{"path":"https://atorus-research.github.io/Tplyr/reference/replace_leading_whitespace.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reformat strings with leading whitespace for HTML — replace_leading_whitespace","text":"x Target string tab_width Number spaces compensate tabs","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/replace_leading_whitespace.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reformat strings with leading whitespace for HTML — replace_leading_whitespace","text":"String   replaced leading whitespace","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/replace_leading_whitespace.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Reformat strings with leading whitespace for HTML — replace_leading_whitespace","text":"","code":"x <- c(\" Hello there\", \" Goodbye Friend \", \"\\tNice to meet you\", \" \\t What are you up to? \\t \\t \") replace_leading_whitespace(x) #> [1] \" Hello there\" #> [2] \"  Goodbye Friend \" #> [3] \"    Nice to meet you\" #> [4] \"       What are you up to? \\t \\t \" replace_leading_whitespace(x, tab=2) #> [1] \" Hello there\" #> [2] \"  Goodbye Friend \" #> [3] \"  Nice to meet you\" #> [4] \"     What are you up to? \\t \\t \""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_custom_summaries.html","id":null,"dir":"Reference","previous_headings":"","what":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","title":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","text":"function allows user define custom summaries performed call dplyr::summarize(). custom summary name default summary override default. allows user override default behavior summaries built 'Tplyr', also adding new desired summary functions.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_custom_summaries.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","text":"","code":"set_custom_summaries(e, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_custom_summaries.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","text":"e desc layer summaries bound ... Named parameters containing syntax used call dplyr::summarize()","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_custom_summaries.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","text":"Binds variable custom_summaries specified layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_custom_summaries.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","text":"programming logic summary function, use variable name .var within summary functions. allows apply summary function variable multiple target variables declared. important, yet immediately obvious, part using set_custom_summaries understand link named parameters set set_custom_summaries names called f_str objects within set_format_strings. f_str, supply string format like numbers take, specify summaries fill strings. go set format strings, name use declare summary set_custom_summaries name use f_str call. necessary set_format_strings needs means putting two summaries value, setting row label summary performed. Review examples see put practice. Note relationship name created set_custom_summaries name used set_format_strings within f_str call","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_custom_summaries.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set custom summaries to be performed within a descriptive statistics layer — set_custom_summaries","text":"","code":"#Load in pipe library(magrittr) tplyr_table(iris, Species) %>% add_layer( group_desc(Sepal.Length, by = \"Sepal Length\") %>% set_custom_summaries( geometric_mean = exp(sum(log(.var[.var > 0]), na.rm=TRUE) / length(.var)) ) %>% set_format_strings( 'Geometric Mean' = f_str('xx.xx', geometric_mean) ) ) %>% build() #> # A tibble: 1 × 8 #> row_label1 row_label2 var1_setosa var1_versicolor var1_virginica #> #> 1 Sepal Length Geometric Mean \" 4.99\" \" 5.91\" \" 6.56\" #> # ℹ 3 more variables: ord_layer_index , ord_layer_1 , #> # ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_ignore.html","id":null,"dir":"Reference","previous_headings":"","what":"Set values the denominator calculation will ignore — set_denom_ignore","title":"Set values the denominator calculation will ignore — set_denom_ignore","text":"`r lifecycle::badge(\"defunct\")` generally used missing values. Values like \"\", NA, \"NA\" common ways missing values presented data frame. certain cases, percentages use \"missing\" values denominator. function notes different values \"missing\" excludes denominators.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_ignore.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set values the denominator calculation will ignore — set_denom_ignore","text":"","code":"set_denom_ignore(e, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_ignore.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set values the denominator calculation will ignore — set_denom_ignore","text":"e count_layer object ... Values exclude percentage calculation. use `set_missing_counts()` name parameters instead values, see example .","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_ignore.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set values the denominator calculation will ignore — set_denom_ignore","text":"modified layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_ignore.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set values the denominator calculation will ignore — set_denom_ignore","text":"","code":"library(magrittr) mtcars2 <- mtcars mtcars2[mtcars$cyl == 6, \"cyl\"] <- NA mtcars2[mtcars$cyl == 8, \"cyl\"] <- \"Not Found\" tplyr_table(mtcars2, gear) %>% add_layer( group_count(cyl) %>% set_missing_count(f_str(\"xx \", n), Missing = c(NA, \"Not Found\")) # This function is currently deprecated. It was replaced with an # argument in set_missing_count # set_denom_ignore(\"Missing\") ) %>% build() #> # A tibble: 2 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 Missing \"14 \" \" 4 \" \" 3 \" 1 3"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_where.html","id":null,"dir":"Reference","previous_headings":"","what":"Set Logic for denominator subsetting — set_denom_where","title":"Set Logic for denominator subsetting — set_denom_where","text":"default, denominators count layers subset based layer level logic. cases might correct. functions allows user override behavior pass custom logic used subset target dataset calculating denominators layer.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_where.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set Logic for denominator subsetting — set_denom_where","text":"","code":"set_denom_where(e, denom_where)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_where.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set Logic for denominator subsetting — set_denom_where","text":"e count_layer/shift_layer object denom_where expression (.e. syntax) used subset target dataset calculating layer denominators. Supply programming logic (.e. x < 5 & y == 10). remove layer parameter subsetting total row thus percentage denominators, pass 'TRUE' function.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_where.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set Logic for denominator subsetting — set_denom_where","text":"modified Tplyr layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denom_where.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set Logic for denominator subsetting — set_denom_where","text":"","code":"library(magrittr) t10 <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl, where = cyl != 6) %>% set_denom_where(TRUE) # The denominators will be based on all of the values, including 6 ) %>% build()"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denoms_by.html","id":null,"dir":"Reference","previous_headings":"","what":"Set variables used in pct denominator calculation — set_denoms_by","title":"Set variables used in pct denominator calculation — set_denoms_by","text":"function used calculating pct count shift layers. percentages default treatment variable column variables can calculated variables passed target_var, treat_var, , cols.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denoms_by.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set variables used in pct denominator calculation — set_denoms_by","text":"","code":"set_denoms_by(e, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denoms_by.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set variables used in pct denominator calculation — set_denoms_by","text":"e count/shift layer object ... Unquoted variable names","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denoms_by.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set variables used in pct denominator calculation — set_denoms_by","text":"modified layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_denoms_by.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set variables used in pct denominator calculation — set_denoms_by","text":"","code":"library(magrittr) # Default has matrix of treatment group, additional columns, # and by variables sum to 1 tplyr_table(mtcars, am) %>% add_layer( group_shift(vars(row=gear, column=carb), by=cyl) %>% set_format_strings(f_str(\"xxx (xx.xx%)\", n, pct)) ) %>% build() #> # A tibble: 9 × 17 #> row_label1 row_label2 var1_0_1 var1_0_2 var1_0_3 var1_0_4 var1_0_6 var1_0_8 #> #> 1 4 3 \" 1 (33.3… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 2 4 4 \" 0 ( 0.0… \" 2 (6… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 3 4 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 4 6 3 \" 2 (50.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 5 6 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 2 (5… \" 0 ( … \" 0 ( … #> 6 6 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 7 8 3 \" 0 ( 0.0… \" 4 (3… \" 3 (2… \" 5 (4… \" 0 ( … \" 0 ( … #> 8 8 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 9 8 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> # ℹ 9 more variables: var1_1_1 , var1_1_2 , var1_1_3 , #> # var1_1_4 , var1_1_6 , var1_1_8 , ord_layer_index , #> # ord_layer_1 , ord_layer_2 tplyr_table(mtcars, am) %>% add_layer( group_shift(vars(row=gear, column=carb), by=cyl) %>% set_format_strings(f_str(\"xxx (xx.xx%)\", n, pct)) %>% set_denoms_by(cyl, gear) # Row % sums to 1 ) %>% build() #> # A tibble: 9 × 17 #> row_label1 row_label2 var1_0_1 var1_0_2 var1_0_3 var1_0_4 var1_0_6 var1_0_8 #> #> 1 4 3 \" 1 (100.… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 2 4 4 \" 0 ( 0.0… \" 2 (2… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 3 4 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 4 6 3 \" 2 (100.… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 5 6 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 2 (5… \" 0 ( … \" 0 ( … #> 6 6 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 7 8 3 \" 0 ( 0.0… \" 4 (3… \" 3 (2… \" 5 (4… \" 0 ( … \" 0 ( … #> 8 8 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 9 8 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> # ℹ 9 more variables: var1_1_1 , var1_1_2 , var1_1_3 , #> # var1_1_4 , var1_1_6 , var1_1_8 , ord_layer_index , #> # ord_layer_1 , ord_layer_2 tplyr_table(mtcars, am) %>% add_layer( group_shift(vars(row=gear, column=carb), by=cyl) %>% set_format_strings(f_str(\"xxx (xx.xx%)\", n, pct)) %>% set_denoms_by(cyl, gear, am) # % within treatment group sums to 1 ) %>% build() #> # A tibble: 9 × 17 #> row_label1 row_label2 var1_0_1 var1_0_2 var1_0_3 var1_0_4 var1_0_6 var1_0_8 #> #> 1 4 3 \" 1 (100.… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 2 4 4 \" 0 ( 0.0… \" 2 (1… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 3 4 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 4 6 3 \" 2 (100.… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 5 6 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 2 (1… \" 0 ( … \" 0 ( … #> 6 6 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 7 8 3 \" 0 ( 0.0… \" 4 (3… \" 3 (2… \" 5 (4… \" 0 ( … \" 0 ( … #> 8 8 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 9 8 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> # ℹ 9 more variables: var1_1_1 , var1_1_2 , var1_1_3 , #> # var1_1_4 , var1_1_6 , var1_1_8 , ord_layer_index , #> # ord_layer_1 , ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/reference/set_distinct_by.html","id":null,"dir":"Reference","previous_headings":"","what":"Set counts to be distinct by some grouping variable. — set_distinct_by","title":"Set counts to be distinct by some grouping variable. — set_distinct_by","text":"situations, count summaries may want see distinct counts variable like subject. example, number subjects population particular adverse event. set_distinct_by allows set variables used determine distinct count.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_distinct_by.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set counts to be distinct by some grouping variable. — set_distinct_by","text":"","code":"set_distinct_by(e, distinct_by)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_distinct_by.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set counts to be distinct by some grouping variable. — set_distinct_by","text":"e count_layer/shift_layer object distinct_by Variable(s) get distinct data.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_distinct_by.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set counts to be distinct by some grouping variable. — set_distinct_by","text":"layer object ","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_distinct_by.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Set counts to be distinct by some grouping variable. — set_distinct_by","text":"distinct_by value set, distinct counts used default. wish combine distinct distinct counts, can choose display f_str() objects using n, pct, distinct_n, distinct_pct. Additionally, denominators may presented using total distinct_total","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_distinct_by.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set counts to be distinct by some grouping variable. — set_distinct_by","text":"","code":"#Load in pipe library(magrittr) tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% set_distinct_by(carb) ) %>% build() #> # A tibble: 3 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 25.0%)\" \" 2 ( 66.7%)\" \" 1 ( 25.0… 1 1 #> 2 6 \" 1 ( 25.0%)\" \" 1 ( 33.3%)\" \" 1 ( 25.0… 1 2 #> 3 8 \" 3 ( 75.0%)\" \" 0 ( 0.0%)\" \" 2 ( 50.0… 1 3"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_format_strings.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","title":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","text":"'Tplyr' gives extensive control strings presented. set_format_strings allows apply string formats layer. behaves slightly differently layers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_format_strings.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","text":"","code":"set_format_strings(e, ...) # S3 method for desc_layer set_format_strings(e, ..., cap = getOption(\"tplyr.precision_cap\")) # S3 method for count_layer set_format_strings(e, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_format_strings.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","text":"e Layer bind format strings ... Named parameters containing calls f_str set format strings cap named character vector containing 'int' element cap integer precision, 'dec' element cap decimal precision.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_format_strings.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","text":"layer environment format string binding added tplyr_layer object formats attached Returns modified layer object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_format_strings.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","text":"Format strings one powerful components 'Tplyr'. Traditionally, converting numeric values strings presentation can consume good deal time. Values decimals need align rows, rounding trimming sometimes forgotten - can become tedious mess , grand scheme things, important part analysis performed. 'Tplyr' makes process simple can, still allowing flexibility user. count layer, can simply provide single f_str object specify want n's, percentages, denominators formatted. additionally supplying statistic, like risk difference using add_risk_diff, specify count formats using name 'n_counts'. risk difference formats specified using name 'riskdiff'. descriptive statistic layer, set_format_strings allows couple things: naming parameters character strings, character strings become row label resulting data frame actual summaries performed come variable names used within f_str calls Using multiple summaries (declared f_str calls), multiple summary values can appear within line. example, present \"Mean (SD)\" like displays. Format strings desc layer also allow configure empty values presented. f_str call, use empty parameter specify missing values present. single element character vector provided. vector unnamed, value used format string fill space similar numbers display. Meaning - empty string 'NA' format string 'xx (xxx)', empty values populate 'NA ( NA)'. name character vector 'empty' parameter '.overall', like empty = c(.overall=''), exact string fill value instead. example, providing 'NA' instead create formatted string 'NA' exactly. See f_str documentation details implementation works.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_format_strings.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the format strings and associated summaries to be performed in a layer — set_format_strings","text":"","code":"# Load in pipe library(magrittr) # In a count layer tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% set_format_strings(f_str('xx (xx%)', n, pct)) ) %>% build() #> # A tibble: 3 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 7%)\" \" 8 (67%)\" \" 2 (40%)\" 1 1 #> 2 6 \" 2 (13%)\" \" 4 (33%)\" \" 1 (20%)\" 1 2 #> 3 8 \"12 (80%)\" \" 0 ( 0%)\" \" 2 (40%)\" 1 3 # In a descriptive statistics layer tplyr_table(mtcars, gear) %>% add_layer( group_desc(mpg) %>% set_format_strings( \"n\" = f_str(\"xx\", n), \"Mean (SD)\" = f_str(\"xx.x\", mean, empty='NA'), \"SD\" = f_str(\"xx.xx\", sd), \"Median\" = f_str(\"xx.x\", median), \"Q1, Q3\" = f_str(\"xx, xx\", q1, q3, empty=c(.overall='NA')), \"Min, Max\" = f_str(\"xx, xx\", min, max), \"Missing\" = f_str(\"xx\", missing) ) ) %>% build() #> # A tibble: 7 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 n \"15\" \"12\" \" 5\" 1 1 #> 2 Mean (SD) \"16.1\" \"24.5\" \"21.4\" 1 2 #> 3 SD \" 3.37\" \" 5.28\" \" 6.66\" 1 3 #> 4 Median \"15.5\" \"22.8\" \"19.7\" 1 4 #> 5 Q1, Q3 \"14, 18\" \"21, 28\" \"16, 26\" 1 5 #> 6 Min, Max \"10, 22\" \"18, 34\" \"15, 30\" 1 6 #> 7 Missing \" 0\" \" 0\" \" 0\" 1 7 # In a shift layer tplyr_table(mtcars, am) %>% add_layer( group_shift(vars(row=gear, column=carb), by=cyl) %>% set_format_strings(f_str(\"xxx (xx.xx%)\", n, pct)) ) %>% build() #> # A tibble: 9 × 17 #> row_label1 row_label2 var1_0_1 var1_0_2 var1_0_3 var1_0_4 var1_0_6 var1_0_8 #> #> 1 4 3 \" 1 (33.3… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 2 4 4 \" 0 ( 0.0… \" 2 (6… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 3 4 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 4 6 3 \" 2 (50.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 5 6 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 2 (5… \" 0 ( … \" 0 ( … #> 6 6 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 7 8 3 \" 0 ( 0.0… \" 4 (3… \" 3 (2… \" 5 (4… \" 0 ( … \" 0 ( … #> 8 8 4 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> 9 8 5 \" 0 ( 0.0… \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … \" 0 ( … #> # ℹ 9 more variables: var1_1_1 , var1_1_2 , var1_1_3 , #> # var1_1_4 , var1_1_6 , var1_1_8 , ord_layer_index , #> # ord_layer_1 , ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/reference/set_indentation.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the option to prefix the row_labels in the inner count_layer — set_indentation","title":"Set the option to prefix the row_labels in the inner count_layer — set_indentation","text":"count layer uses nesting (.e. triggered set_nest_count), indentation argument's value used prefix inner layer's records","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_indentation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the option to prefix the row_labels in the inner count_layer — set_indentation","text":"","code":"set_indentation(e, indentation)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_indentation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the option to prefix the row_labels in the inner count_layer — set_indentation","text":"e count_layer object indentation character prefix row labels inner count layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_indentation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the option to prefix the row_labels in the inner count_layer — set_indentation","text":"modified count_layer environment","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_limit_data_by.html","id":null,"dir":"Reference","previous_headings":"","what":"Set variables to limit reported data values only to those that exist rather\nthan fully completing all possible levels — set_limit_data_by","title":"Set variables to limit reported data values only to those that exist rather\nthan fully completing all possible levels — set_limit_data_by","text":"function allows select combination variables potentially target variables want display values present data. default, Tplyr create cartesian combination potential values data. example, 2 variables present, potential combination variables row present final table. set_limit_data_by() allows choose variables whose combination wish limit values physically present available data.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_limit_data_by.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set variables to limit reported data values only to those that exist rather\nthan fully completing all possible levels — set_limit_data_by","text":"","code":"set_limit_data_by(e, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_limit_data_by.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set variables to limit reported data values only to those that exist rather\nthan fully completing all possible levels — set_limit_data_by","text":"e tplyr_layer ... Subset variables within target variables","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_limit_data_by.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set variables to limit reported data values only to those that exist rather\nthan fully completing all possible levels — set_limit_data_by","text":"tplyr_table","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_limit_data_by.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set variables to limit reported data values only to those that exist rather\nthan fully completing all possible levels — set_limit_data_by","text":"","code":"tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_desc(AVAL, by = vars(PECAT, PARAM, AVISIT)) ) %>% build() #> # A tibble: 72 × 11 #> row_label1 row_label2 row_label3 row_label4 `var1_TRT A` `var1_TRT B` #> #> 1 A Head Screening n \" 2\" \" 1\" #> 2 A Head Screening Mean (SD) \"5.0 (5.66)\" \"5.0 ( )\" #> 3 A Head Screening Median \"5.0\" \"5.0\" #> 4 A Head Screening Q1, Q3 \"3.0, 7.0\" \"5.0, 5.0\" #> 5 A Head Screening Min, Max \"1, 9\" \"5, 5\" #> 6 A Head Screening Missing \" 0\" \" 0\" #> 7 A Head Day -1 n \"\" \"\" #> 8 A Head Day -1 Mean (SD) \"\" \"\" #> 9 A Head Day -1 Median \"\" \"\" #> 10 A Head Day -1 Q1, Q3 \"\" \"\" #> # ℹ 62 more rows #> # ℹ 5 more variables: ord_layer_index , ord_layer_1 , #> # ord_layer_2 , ord_layer_3 , ord_layer_4 tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_desc(AVAL, by = vars(PECAT, PARAM, AVISIT)) %>% set_limit_data_by(PARAM, AVISIT) ) %>% build() #> # A tibble: 48 × 11 #> row_label1 row_label2 row_label3 row_label4 `var1_TRT A` `var1_TRT B` #> #> 1 A Head Screening n \" 2\" \" 1\" #> 2 A Head Screening Mean (SD) \"5.0 (5.66)\" \"5.0 ( )\" #> 3 A Head Screening Median \"5.0\" \"5.0\" #> 4 A Head Screening Q1, Q3 \"3.0, 7.0\" \"5.0, 5.0\" #> 5 A Head Screening Min, Max \"1, 9\" \"5, 5\" #> 6 A Head Screening Missing \" 0\" \" 0\" #> 7 B Head Screening n \"\" \"\" #> 8 B Head Screening Mean (SD) \"\" \"\" #> 9 B Head Screening Median \"\" \"\" #> 10 B Head Screening Q1, Q3 \"\" \"\" #> # ℹ 38 more rows #> # ℹ 5 more variables: ord_layer_index , ord_layer_1 , #> # ord_layer_2 , ord_layer_3 , ord_layer_4 tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_count(AVALC, by = vars(PECAT, PARAM, AVISIT)) %>% set_limit_data_by(PARAM, AVISIT) ) %>% build() #> # A tibble: 24 × 11 #> row_label1 row_label2 row_label3 row_label4 `var1_TRT A` `var1_TRT B` #> #> 1 A Head Screening Normal 2 ( 14.3%) 0 ( 0.0%) #> 2 A Head Screening Semi-Normal 0 ( 0.0%) 1 ( 14.3%) #> 3 A Head Screening Abnormal 0 ( 0.0%) 0 ( 0.0%) #> 4 B Head Screening Normal 0 ( 0.0%) 0 ( 0.0%) #> 5 B Head Screening Semi-Normal 0 ( 0.0%) 0 ( 0.0%) #> 6 B Head Screening Abnormal 0 ( 0.0%) 0 ( 0.0%) #> 7 A Lungs Screening Normal 1 ( 7.1%) 1 ( 14.3%) #> 8 A Lungs Screening Semi-Normal 0 ( 0.0%) 0 ( 0.0%) #> 9 A Lungs Screening Abnormal 1 ( 7.1%) 0 ( 0.0%) #> 10 B Lungs Screening Normal 1 ( 7.1%) 1 ( 14.3%) #> # ℹ 14 more rows #> # ℹ 5 more variables: ord_layer_index , ord_layer_1 , #> # ord_layer_2 , ord_layer_3 , ord_layer_4 tplyr_table(tplyr_adpe, TRT01A) %>% add_layer( group_count(AVALC, by = vars(PECAT, PARAM, AVISIT)) %>% set_limit_data_by(PECAT, PARAM, AVISIT) ) %>% build() #> # A tibble: 21 × 11 #> row_label1 row_label2 row_label3 row_label4 `var1_TRT A` `var1_TRT B` #> #> 1 A Head Screening Normal 2 ( 14.3%) 0 ( 0.0%) #> 2 A Head Screening Semi-Normal 0 ( 0.0%) 1 ( 14.3%) #> 3 A Head Screening Abnormal 0 ( 0.0%) 0 ( 0.0%) #> 4 A Lungs Screening Normal 1 ( 7.1%) 1 ( 14.3%) #> 5 A Lungs Screening Semi-Normal 0 ( 0.0%) 0 ( 0.0%) #> 6 A Lungs Screening Abnormal 1 ( 7.1%) 0 ( 0.0%) #> 7 A Lungs Day -1 Normal 2 ( 14.3%) 1 ( 14.3%) #> 8 A Lungs Day -1 Semi-Normal 0 ( 0.0%) 0 ( 0.0%) #> 9 A Lungs Day -1 Abnormal 0 ( 0.0%) 0 ( 0.0%) #> 10 A Lungs Day 5 Normal 1 ( 7.1%) 1 ( 14.3%) #> # ℹ 11 more rows #> # ℹ 5 more variables: ord_layer_index , ord_layer_1 , #> # ord_layer_2 , ord_layer_3 , ord_layer_4 "},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_count.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the display for missing strings — set_missing_count","title":"Set the display for missing strings — set_missing_count","text":"Controls missing counts handled displayed layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_count.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the display for missing strings — set_missing_count","text":"","code":"set_missing_count(e, fmt = NULL, sort_value = NULL, denom_ignore = FALSE, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_count.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the display for missing strings — set_missing_count","text":"e count_layer object fmt f_str object change display missing counts sort_value numeric value used ordering column. numeric. supplied ordering column maximum value appears table plus one. denom_ignore boolean. Specifies Whether include missing counts specified within ... parameter within denominators. set TRUE, values specified within ... ignored. ... Parameters used note values describe missing. Generally NA \"Missing\" used . Parameters can named character vectors names become row label.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_count.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the display for missing strings — set_missing_count","text":"modified layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_count.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the display for missing strings — set_missing_count","text":"","code":"library(magrittr) library(dplyr) mtcars2 <- mtcars %>% mutate_all(as.character) mtcars2[mtcars$cyl == 6, \"cyl\"] <- NA tplyr_table(mtcars2, gear) %>% add_layer( group_count(cyl) %>% set_missing_count(f_str(\"xx \", n), Missing = NA) ) %>% build() #> # A tibble: 3 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 8 \"12 ( 80.0%)\" \" 0 ( 0.0%)\" \" 2 ( 40.0… 1 2 #> 3 Missing \" 2 \" \" 4 \" \" 1 \" 1 3"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_subjects_row_label.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the label for the missing subjects row — set_missing_subjects_row_label","title":"Set the label for the missing subjects row — set_missing_subjects_row_label","text":"Set label missing subjects row","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_subjects_row_label.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the label for the missing subjects row — set_missing_subjects_row_label","text":"","code":"set_missing_subjects_row_label(e, missing_subjects_row_label)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_subjects_row_label.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the label for the missing subjects row — set_missing_subjects_row_label","text":"e count_layer object missing_subjects_row_label character label total row","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_subjects_row_label.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the label for the missing subjects row — set_missing_subjects_row_label","text":"modified count_layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_missing_subjects_row_label.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the label for the missing subjects row — set_missing_subjects_row_label","text":"","code":"t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% add_missing_subjects_row() %>% set_missing_subjects_row_label(\"Missing\") ) #> Warning: \tPopulation data was not set separately from the target data. #> \tMissing subject counts may be misleading in this scenario. #> \tDid you mean to use `set_missing_count() instead? build(t) #> # A tibble: 4 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 6 \" 2 ( 13.3%)\" \" 4 ( 33.3%)\" \" 1 ( 20.0… 1 2 #> 3 8 \"12 ( 80.0%)\" \" 0 ( 0.0%)\" \" 2 ( 40.0… 1 3 #> 4 Missing \" ( 0.0%)\" \" ( 0.0%)\" \" ( 0.0… 1 4"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_nest_count.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the option to nest count layers — set_nest_count","title":"Set the option to nest count layers — set_nest_count","text":"set TRUE, second variable specified target_var nested inside first variable. allows create displays like commonly used adverse event tables, one column holds labels outer categorical variable inside event variable (.e. AEBODSYS AEDECOD).","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_nest_count.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the option to nest count layers — set_nest_count","text":"","code":"set_nest_count(e, nest_count)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_nest_count.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the option to nest count layers — set_nest_count","text":"e count_layer object nest_count logical value set nest option","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_nest_count.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the option to nest count layers — set_nest_count","text":"modified layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_numeric_threshold.html","id":null,"dir":"Reference","previous_headings":"","what":"Set a numeric cutoff — set_numeric_threshold","title":"Set a numeric cutoff — set_numeric_threshold","text":"certain tables, may necessary include rows meet numeric conditions. Rows less certain cutoff can suppressed output. function allows pass cutoff, cutoff stat(n, distinct_n, pct, distinct_pct) supress values lesser cutoff.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_numeric_threshold.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set a numeric cutoff — set_numeric_threshold","text":"","code":"set_numeric_threshold(e, numeric_cutoff, stat, column = NULL)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_numeric_threshold.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set a numeric cutoff — set_numeric_threshold","text":"e count_layer object numeric_cutoff numeric value values greater equal displayed. stat statistic use filtering rows. Either 'n', 'distinct_n', 'pct' allowable column particular column used cutoff values, can supplied character value.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_numeric_threshold.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set a numeric cutoff — set_numeric_threshold","text":"modified Tplyr layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_numeric_threshold.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set a numeric cutoff — set_numeric_threshold","text":"","code":"mtcars %>% tplyr_table(gear) %>% add_layer( group_count(cyl) %>% set_numeric_threshold(10, \"n\") %>% add_total_row() %>% set_order_count_method(\"bycount\") ) #> *** tplyr_table *** #> Target (data.frame): #> \tName: . #> \tRows: 32 #> \tColumns: 11 #> treat_var variable (quosure) #> \tgear #> header_n: header groups #> treat_grps groupings (list) #> Table Columns (cols): #> where: TRUE #> Number of layer(s): 1 #> layer_output: 0"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_outer_sort_position.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the value of a outer nested count layer to Inf or -Inf — set_outer_sort_position","title":"Set the value of a outer nested count layer to Inf or -Inf — set_outer_sort_position","text":"Set value outer nested count layer Inf -Inf","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_outer_sort_position.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the value of a outer nested count layer to Inf or -Inf — set_outer_sort_position","text":"","code":"set_outer_sort_position(e, outer_sort_position)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_outer_sort_position.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the value of a outer nested count layer to Inf or -Inf — set_outer_sort_position","text":"e count_layer object outer_sort_position Either 'asc' 'desc'. desc final ordering helper set Inf, 'asc' ordering helper set -Inf.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_outer_sort_position.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the value of a outer nested count layer to Inf or -Inf — set_outer_sort_position","text":"modified count layer.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_precision_data.html","id":null,"dir":"Reference","previous_headings":"","what":"Set precision data — set_precision_data","title":"Set precision data — set_precision_data","text":"cases, may organizational standards surrounding decimal precision. example, may specific standard around representation precision relating lab results. , set_precision_data() provides interface provide integer decimal precision external data source.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_precision_data.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set precision data — set_precision_data","text":"","code":"set_precision_data(layer, prec, default = c(\"error\", \"auto\"))"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_precision_data.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set precision data — set_precision_data","text":"layer tplyr_layer object prec dataframe following structure specified function details default Handling unspecified variable groupings. Defaults 'error'. Set 'auto' automatically infer missing groups.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_precision_data.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Set precision data — set_precision_data","text":"ultimate behavior feature just existing auto precision method, except precision specified provided precision dataset rather inferred source data. minimum, precision dataset must contain integer variables max_int max_dec. variables provided, variables must available layer variables. table built, default Tplyr error precision dataset missing variable groupings exist target dataset. can overriden using default parameter. default set \"auto\", missing values automatically inferred source data.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_precision_data.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set precision data — set_precision_data","text":"","code":"prec <- tibble::tribble( ~vs, ~max_int, ~max_dec, 0, 1, 1, 1, 2, 2 ) tplyr_table(mtcars, gear) %>% add_layer( group_desc(wt, by = vs) %>% set_format_strings( 'Mean (SD)' = f_str('a.a+1 (a.a+2)', mean, sd) ) %>% set_precision_data(prec) %>% set_precision_on(wt) ) %>% build() #> # A tibble: 2 × 8 #> row_label1 row_label2 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 0 Mean (SD) \"4.10 (0.768)\" \"2.75… \"2.91… 1 1 #> 2 1 Mean (SD) \" 3.047 ( 0.5… \" 2.5… \" 1.5… 1 2 #> # ℹ 1 more variable: ord_layer_2 "},{"path":"https://atorus-research.github.io/Tplyr/reference/set_stats_as_columns.html","id":null,"dir":"Reference","previous_headings":"","what":"Set descriptive statistics as columns — set_stats_as_columns","title":"Set descriptive statistics as columns — set_stats_as_columns","text":"many cases, treatment groups represented columns within table. tables call transposed presentation, treatment groups displayed row, descriptive statistics represented columns. set_stats_as_columns() allows Tplyr output built table using transposed format deviate away standard representation treatment groups columns.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_stats_as_columns.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set descriptive statistics as columns — set_stats_as_columns","text":"","code":"set_stats_as_columns(e, stats_as_columns = TRUE)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_stats_as_columns.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set descriptive statistics as columns — set_stats_as_columns","text":"e desc_layer descriptive statistics summaries represented columns stats_as_columns Boolean set stats columns","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_stats_as_columns.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set descriptive statistics as columns — set_stats_as_columns","text":"input tplyr_layer","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_stats_as_columns.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Set descriptive statistics as columns — set_stats_as_columns","text":"function leaves specified variables intact. switch happens build process provided descriptive statistics transposed columns treatment variable left rows. Column variables remain represented columns, multiple target variables also respected properly.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_stats_as_columns.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set descriptive statistics as columns — set_stats_as_columns","text":"","code":"dat <- tplyr_table(mtcars, gear) %>% add_layer( group_desc(wt, by = vs) %>% set_format_strings( \"n\" = f_str(\"xx\", n), \"sd\" = f_str(\"xx.x\", sd, empty = c(.overall = \"BLAH\")), \"Median\" = f_str(\"xx.x\", median), \"Q1, Q3\" = f_str(\"xx, xx\", q1, q3), \"Min, Max\" = f_str(\"xx, xx\", min, max), \"Missing\" = f_str(\"xx\", missing) ) %>% set_stats_as_columns() ) %>% build()"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_total_row_label.html","id":null,"dir":"Reference","previous_headings":"","what":"Set the label for the total row — set_total_row_label","title":"Set the label for the total row — set_total_row_label","text":"row label total row defaults \"Total\", however can overriden using function.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_total_row_label.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set the label for the total row — set_total_row_label","text":"","code":"set_total_row_label(e, total_row_label)"},{"path":"https://atorus-research.github.io/Tplyr/reference/set_total_row_label.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set the label for the total row — set_total_row_label","text":"e count_layer object total_row_label character label total row","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_total_row_label.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set the label for the total row — set_total_row_label","text":"modified count_layer object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/set_total_row_label.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set the label for the total row — set_total_row_label","text":"","code":"# Load in pipe library(magrittr) t <- tplyr_table(mtcars, gear) %>% add_layer( group_count(cyl) %>% add_total_row() %>% set_total_row_label(\"Total Cyl\") ) build(t) #> # A tibble: 4 × 6 #> row_label1 var1_3 var1_4 var1_5 ord_layer_index ord_layer_1 #> #> 1 4 \" 1 ( 6.7%)\" \" 8 ( 66.7%)\" \" 2 ( 40.0… 1 1 #> 2 6 \" 2 ( 13.3%)\" \" 4 ( 33.3%)\" \" 1 ( 20.0… 1 2 #> 3 8 \"12 ( 80.0%)\" \" 0 ( 0.0%)\" \" 2 ( 40.0… 1 3 #> 4 Total Cyl \"15 (100.0%)\" \"12 (100.0%)\" \" 5 (100.0… 1 4"},{"path":"https://atorus-research.github.io/Tplyr/reference/str_extractors.html","id":null,"dir":"Reference","previous_headings":"","what":"Extract format group strings or numbers — str_extract_fmt_group","title":"Extract format group strings or numbers — str_extract_fmt_group","text":"functions allow extract segments information within result string targetting specific format groups. str_extract_fmt_group() allows pull individual format group string, str_extract_num() allows pull specific numeric result.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_extractors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Extract format group strings or numbers — str_extract_fmt_group","text":"","code":"str_extract_fmt_group(string, format_group) str_extract_num(string, format_group)"},{"path":"https://atorus-research.github.io/Tplyr/reference/str_extractors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Extract format group strings or numbers — str_extract_fmt_group","text":"string string number results extract format groups format_group integer representing format group extracted","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_extractors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Extract format group strings or numbers — str_extract_fmt_group","text":"character vector","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_extractors.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Extract format group strings or numbers — str_extract_fmt_group","text":"Format groups refer individual segments string. example, given string ' 5 (34.4%) [9]', three separate format groups, ' 5', '(34.4%)', '[9]'.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_extractors.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Extract format group strings or numbers — str_extract_fmt_group","text":"","code":"string <- c(\" 0 (0.0%)\", \" 8 (9.3%)\", \"78 (90.7%)\") str_extract_fmt_group(string, 2) #> [1] \"(0.0%)\" \"(9.3%)\" \"(90.7%)\" str_extract_num(string, 2) #> [1] 0.0 9.3 90.7"},{"path":"https://atorus-research.github.io/Tplyr/reference/str_indent_wrap.html","id":null,"dir":"Reference","previous_headings":"","what":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","title":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","text":"str_indent_wrap() leverages stringr::str_wrap() hood, takes extra steps preserve indentation applied character element, use hyphenated wrapping single words run longer allotted wrapping width.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_indent_wrap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","text":"","code":"str_indent_wrap(x, width = 10, tab_width = 5)"},{"path":"https://atorus-research.github.io/Tplyr/reference/str_indent_wrap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","text":"x input character vector width desired width elements within output character vector tab_width number spaces tabs converted","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_indent_wrap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","text":"character vector string wrapping applied","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_indent_wrap.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","text":"function stringr::str_wrap() highly efficient, context table creation two select features missing - hyphenation long running strings overflow width, respect pre-indentation character element. example, adverse event table, may body system rows un-indented column, preferred terms indented columns. strings may run long require wrapping surpass column width. Furthermore, crowded tables single word may longer column width . function takes steps resolve two issues, trying minimize additional overhead required apply wrapping strings. Note: function automatically converts tabs spaces. Tab width varies depending font, width automatically determined within data frame. , users can specify width","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/str_indent_wrap.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Wrap strings to a specific width with hyphenation while preserving\nindentation — str_indent_wrap","text":"","code":"ex_text1 <- c(\"RENAL AND URINARY DISORDERS\", \" NEPHROLITHIASIS\") ex_text2 <- c(\"RENAL AND URINARY DISORDERS\", \"\\tNEPHROLITHIASIS\") cat(paste(str_indent_wrap(ex_text1, width=8), collapse=\"\\n\\n\"),\"\\n\") #> RENAL #> AND #> URINARY #> DISORDE- #> RS #> #> NEPHROL- #> ITHIASI- #> S cat(paste(str_indent_wrap(ex_text2, tab_width=4), collapse=\"\\n\\n\"),\"\\n\") #> RENAL AND #> URINARY #> DISORDERS #> #> NEPHROLIT- #> HIASIS"},{"path":"https://atorus-research.github.io/Tplyr/reference/table_format_defaults.html","id":null,"dir":"Reference","previous_headings":"","what":"Get or set the default format strings for descriptive statistics layers — get_desc_layer_formats","title":"Get or set the default format strings for descriptive statistics layers — get_desc_layer_formats","text":"Tplyr provides ability set table-wide defaults format strings. may wish reuse format strings across numerous layers. set_desc_layer_formats set_count_layer_formats allow apply desired format strings within entire scope table.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/table_format_defaults.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get or set the default format strings for descriptive statistics layers — get_desc_layer_formats","text":"","code":"get_desc_layer_formats(obj) set_desc_layer_formats(obj, ...) get_count_layer_formats(obj) set_count_layer_formats(obj, ...) get_shift_layer_formats(obj) set_shift_layer_formats(obj, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/table_format_defaults.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get or set the default format strings for descriptive statistics layers — get_desc_layer_formats","text":"obj tplyr_table object ... formats pass forward","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/table_format_defaults.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Get or set the default format strings for descriptive statistics layers — get_desc_layer_formats","text":"descriptive statistic layers, can also use set_format_strings set_desc_layer_formats together within table, within layer. absence specified format strings, first table checked available defaults, otherwise tplyr.desc_layer_default_formats option used. set_format_strings always take precedence either. Defaults combined set_format_strings, set_desc_layer_formats, tplyr.desc_layer_default_formats order presentation results controlled format strings, relying combinations setting intuitive. count layers, can override n_counts riskdiff format strings separately, narrowest scope available used layer, table, default options.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/target_var.html","id":null,"dir":"Reference","previous_headings":"","what":"Set or return treat_var binding — get_target_var","title":"Set or return treat_var binding — get_target_var","text":"Set return treat_var binding","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/target_var.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set or return treat_var binding — get_target_var","text":"","code":"get_target_var(layer) set_target_var(layer, target_var)"},{"path":"https://atorus-research.github.io/Tplyr/reference/target_var.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set or return treat_var binding — get_target_var","text":"layer tplyr_layer object target_var symbol perform analysis ","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/target_var.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set or return treat_var binding — get_target_var","text":"treat_var, treatment variable binding layer object. set_treat_var, modified layer environment.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/target_var.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set or return treat_var binding — get_target_var","text":"","code":"# Load in pipe library(magrittr) iris$Species2 <- iris$Species lay <- tplyr_table(iris, Species) %>% group_count(Species) %>% set_target_var(Species2)"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adae.html","id":null,"dir":"Reference","previous_headings":"","what":"ADAE Data — tplyr_adae","title":"ADAE Data — tplyr_adae","text":"subset PHUSE Test Data Factory ADAE data set.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adae.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ADAE Data — tplyr_adae","text":"","code":"tplyr_adae"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adae.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"ADAE Data — tplyr_adae","text":"data.frame 276 rows 55 columns.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adae.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"ADAE Data — tplyr_adae","text":"https://github.com/phuse-org/TestDataFactory","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adas.html","id":null,"dir":"Reference","previous_headings":"","what":"ADAS Data — tplyr_adas","title":"ADAS Data — tplyr_adas","text":"subset PHUSE Test Data Factory ADAS data set.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adas.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ADAS Data — tplyr_adas","text":"","code":"tplyr_adas"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adas.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"ADAS Data — tplyr_adas","text":"data.frame 1,040 rows 40 columns.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adas.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"ADAS Data — tplyr_adas","text":"https://github.com/phuse-org/TestDataFactory","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adlb.html","id":null,"dir":"Reference","previous_headings":"","what":"ADLB Data — tplyr_adlb","title":"ADLB Data — tplyr_adlb","text":"subset PHUSE Test Data Factory ADLB data set.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adlb.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ADLB Data — tplyr_adlb","text":"","code":"tplyr_adlb"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adlb.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"ADLB Data — tplyr_adlb","text":"data.frame 311 rows 46 columns.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adlb.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"ADLB Data — tplyr_adlb","text":"https://github.com/phuse-org/TestDataFactory","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adpe.html","id":null,"dir":"Reference","previous_headings":"","what":"ADPE Data — tplyr_adpe","title":"ADPE Data — tplyr_adpe","text":"mock-dataset fit testing data limiting","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adpe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ADPE Data — tplyr_adpe","text":"","code":"tplyr_adpe"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adpe.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"ADPE Data — tplyr_adpe","text":"data.frame 21 rows 8 columns.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adsl.html","id":null,"dir":"Reference","previous_headings":"","what":"ADSL Data — tplyr_adsl","title":"ADSL Data — tplyr_adsl","text":"subset PHUSE Test Data Factory ADSL data set.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adsl.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"ADSL Data — tplyr_adsl","text":"","code":"tplyr_adsl"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adsl.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"ADSL Data — tplyr_adsl","text":"data.frame 254 rows 49 columns.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_adsl.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"ADSL Data — tplyr_adsl","text":"https://github.com/phuse-org/TestDataFactory","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_layer.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a tplyr_layer object — tplyr_layer","title":"Create a tplyr_layer object — tplyr_layer","text":"object workhorse tplyr package. tplyr_layer can thought block, \"layer\" table. Summary tables typically consist different sections require different summaries. programming section, code create different layers need stacked merged together. tplyr_layer container isolated building blocks. building tplyr_table, layer execute independently. data processing completed, layers brought together construct output. tplyr_layer objects created directly, rather created using layer constructor functions group_count, group_desc, group_shift.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_layer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a tplyr_layer object — tplyr_layer","text":"","code":"tplyr_layer(parent, target_var, by, where, type, ...)"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_layer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a tplyr_layer object — tplyr_layer","text":"parent tplyr_table tplyr_layer. Required. parent environment layer. must either tplyr_table object layer contained within, another tplyr_layer object layer subgroup. target_var Symbol. Required, variable name summary performed. Must variable within target dataset. Enter unquoted - .e. target_var = AEBODSYS. string, variable name, list variable names supplied using dplyr::vars Call. Filter logic used subset target data performing summary. type \"count\", \"desc\", \"shift\". Required. category layer - either \"counts\" categorical counts, \"desc\" descriptive statistics, \"shift\" shift table counts ... Additional arguments","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_layer.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a tplyr_layer object — tplyr_layer","text":"tplyr_layer environment child specified parent. environment contains object listed .","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_layer.html","id":"tplyr-layer-core-object-structure","dir":"Reference","previous_headings":"","what":"tplyr_layer Core Object Structure","title":"Create a tplyr_layer object — tplyr_layer","text":"type attribute. string indicating layer type, controls summary performed. target_var quosure name, variable summary performed. list quosures representing either text labels variable names used grouping. Variable names must exist within target dataset Text strings submitted need exist target dataset. cols list quosures used determine variables used display columns. quosure call containers filter logic used subset target dataset. filtering addition subsetting done based criteria specified tplyr_table layers list class tplyr_layer_container. Initialized empty, serves container sublayers current layer. Used internally. Different layer types different bindings specific layer's needs.","code":""},{"path":[]},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_layer.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a tplyr_layer object — tplyr_layer","text":"","code":"tab <- tplyr_table(iris, Sepal.Width) l <- group_count(tab, by=vars('Label Text', Species), target_var=Species, where= Sepal.Width < 5.5, cols = Species)"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_meta.html","id":null,"dir":"Reference","previous_headings":"","what":"Tplyr Metadata Object — tplyr_meta","title":"Tplyr Metadata Object — tplyr_meta","text":"Tplyr table built `metadata=TRUE` option specified, metadata assembled behind scenes provide traceability result cell derived. functions `get_meta_result()` `get_meta_subset()` allow access metadata using ID provided row_id column column name result like access. purpose row_id variable instead simple row index provide sort resistant reference originating column, output Tplyr table can sorted order metadata still easily accessible.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_meta.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tplyr Metadata Object — tplyr_meta","text":"","code":"tplyr_meta(names = list(), filters = exprs())"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_meta.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tplyr Metadata Object — tplyr_meta","text":"names List symbols filters List expressions","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_meta.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tplyr Metadata Object — tplyr_meta","text":"tplyr_meta object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_meta.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Tplyr Metadata Object — tplyr_meta","text":"`tplyr_meta` object provided list two elements - names filters. names contain every column target data.frame Tplyr table factored specified result cell, filters contains necessary filters subset target data create specified result cell. `get_meta_subset()` additionally provides parameter specify additional columns like include returned subset data frame.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_meta.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Tplyr Metadata Object — tplyr_meta","text":"","code":"tplyr_meta( names = rlang::quos(x, y, z), filters = rlang::quos(x == 1, y==2, z==3) ) #> tplyr_meta: 3 names, 3 filters #> Names: #> x, y, z #> Filters: #> x == 1, y == 2, z == 3"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_table.html","id":null,"dir":"Reference","previous_headings":"","what":"Create a Tplyr table object — tplyr_table","title":"Create a Tplyr table object — tplyr_table","text":"tplyr_table object main container upon Tplyr table constructed. Tplyr tables made one layers. layer contains instruction summary performed. tplyr_table object contains layers, general data, metadata, logic necessary.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_table.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create a Tplyr table object — tplyr_table","text":"","code":"tplyr_table(target, treat_var, where = TRUE, cols = vars())"},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_table.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create a Tplyr table object — tplyr_table","text":"target Dataset upon summaries performed treat_var Variable containing treatment group assignments. Supply unquoted. general subset applied layers. Supply programming logic (.e. x < 5 & y == 10) cols grouping variable summarize data column (addition treat_var). Provide multiple column variables using vars","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_table.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create a Tplyr table object — tplyr_table","text":"tplyr_table object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_table.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Create a Tplyr table object — tplyr_table","text":"tplyr_table created, contain following bindings: target - dataset upon summaries performed pop_data - data containing population information. defaults target dataset cols - categorical variable present summaries grouped column (addition treat_var) table_where - parameter provided, used subset target data treat_var - Variable used distinguish treatment groups. header_n - Default header N values based treat_var pop_treat_var - treatment variable pop_data (different) layers - container individual layers tplyr_table treat_grps - Additional treatment groups added summary (.e. Total) tplyr_table allows basic interface instantiate object. Modifier functions available change individual parameters catered analysis. example, add total group, can use add_total_group. future releases, provide vignettes fully demonstrate capabilities.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/tplyr_table.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Create a Tplyr table object — tplyr_table","text":"","code":"tab <- tplyr_table(iris, Species, where = Sepal.Length < 5.8)"},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_grps.html","id":null,"dir":"Reference","previous_headings":"","what":"Combine existing treatment groups for summary — add_treat_grps","title":"Combine existing treatment groups for summary — add_treat_grps","text":"Summary tables often present individual treatment groups, may additionally \"Treatment vs. Placebo\" \"Total\" group added show grouped summary statistics counts. set functions offers interface add groups table level consumed subsequent layers.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_grps.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Combine existing treatment groups for summary — add_treat_grps","text":"","code":"add_treat_grps(table, ...) add_total_group(table, group_name = \"Total\") treat_grps(table)"},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_grps.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Combine existing treatment groups for summary — add_treat_grps","text":"table tplyr_table object ... named vector names become new treatment group names, values used construct treatment groups group_name treatment group name used constructed 'Total' group","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_grps.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Combine existing treatment groups for summary — add_treat_grps","text":"modified table object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_grps.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Combine existing treatment groups for summary — add_treat_grps","text":"add_treat_grps allows specify specific groupings. done supplying named arguments, name becomes new treatment group's name, treatment groups made argument's values. add_total_group simple wrapper around add_treat_grps. Instead producing custom groupings, produces \"Total\" group supplied name, defaults \"Total\". \"Total\" group made existing treatment groups within population dataset. Note using add_treat_grps add_total_row() set_pop_data(), call add_total_row() calling set_pop_data(), otherwise potential unexpected behaivior treatment groups. function treat_grps allows see custom treatment groups available tplyr_table object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_grps.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Combine existing treatment groups for summary — add_treat_grps","text":"","code":"tab <- tplyr_table(iris, Species) # A custom group add_treat_grps(tab, \"Not Setosa\" = c(\"versicolor\", \"virginica\")) #> *** tplyr_table *** #> Target (data.frame): #> \tName: iris #> \tRows: 150 #> \tColumns: 5 #> treat_var variable (quosure) #> \tSpecies #> header_n: header groups #> treat_grps groupings (list) #> \tNot Setosa #> Table Columns (cols): #> where: TRUE #> Number of layer(s): 0 #> layer_output: 0 # Add a total group add_total_group(tab) #> *** tplyr_table *** #> Target (data.frame): #> \tName: iris #> \tRows: 150 #> \tColumns: 5 #> treat_var variable (quosure) #> \tSpecies #> header_n: header groups #> treat_grps groupings (list) #> \tNot Setosa #> \tTotal #> Table Columns (cols): #> where: TRUE #> Number of layer(s): 0 #> layer_output: 0 treat_grps(tab) #> $`Not Setosa` #> [1] \"versicolor\" \"virginica\" #> #> $Total #> [1] \"setosa\" \"versicolor\" \"virginica\" #> # Returns: # $`Not Setosa` #[1] \"versicolor\" \"virginica\" # #$Total #[1] \"setosa\" \"versicolor\" \"virginica\""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_var.html","id":null,"dir":"Reference","previous_headings":"","what":"Return or set the treatment variable binding — treat_var","title":"Return or set the treatment variable binding — treat_var","text":"Return set treatment variable binding","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_var.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return or set the treatment variable binding — treat_var","text":"","code":"treat_var(table) set_treat_var(table, treat_var)"},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_var.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return or set the treatment variable binding — treat_var","text":"table tplyr_table object set return treatment variable table split . treat_var Variable containing treatment group assignments. Supply unquoted.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_var.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return or set the treatment variable binding — treat_var","text":"tplyr_treat_var treat_var binding tplyr_table object. set_tplyr_treat_var modified object.","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/treat_var.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Return or set the treatment variable binding — treat_var","text":"","code":"tab <- tplyr_table(mtcars, cyl) set_treat_var(tab, gear) #> *** tplyr_table *** #> Target (data.frame): #> \tName: mtcars #> \tRows: 32 #> \tColumns: 11 #> treat_var variable (quosure) #> \tgearpop_treat_var variable (quosure) #> \tcyl #> #> header_n: header groups #> treat_grps groupings (list) #> Table Columns (cols): #> where: TRUE #> Number of layer(s): 0 #> layer_output: 0"},{"path":"https://atorus-research.github.io/Tplyr/reference/where.html","id":null,"dir":"Reference","previous_headings":"","what":"Set or return where binding for layer or table — get_where.tplyr_layer","title":"Set or return where binding for layer or table — get_where.tplyr_layer","text":"Set return binding layer table","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/where.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Set or return where binding for layer or table — get_where.tplyr_layer","text":"","code":"# S3 method for tplyr_layer get_where(obj) # S3 method for tplyr_layer set_where(obj, where) get_where(obj) # S3 method for tplyr_table get_where(obj) set_where(obj, where) # S3 method for tplyr_table set_where(obj, where) set_pop_where(obj, where) get_pop_where(obj)"},{"path":"https://atorus-research.github.io/Tplyr/reference/where.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Set or return where binding for layer or table — get_where.tplyr_layer","text":"obj tplyr_layer tplyr_table object. expression (.e. syntax) used subset data. Supply programming logic (.e. x < 5 & y == 10)","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/where.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Set or return where binding for layer or table — get_where.tplyr_layer","text":", binding supplied object. set_where, modified object","code":""},{"path":"https://atorus-research.github.io/Tplyr/reference/where.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Set or return where binding for layer or table — get_where.tplyr_layer","text":"","code":"# Load in pipe library(magrittr) iris$Species2 <- iris$Species lay <- tplyr_table(iris, Species) %>% group_count(Species) %>% set_where(Petal.Length > 3) %>% # Set logic for pop_data as well set_pop_where(Petal.Length > 3)"}]