From e013eb09626dbddcf93d771752551e30f39d91e6 Mon Sep 17 00:00:00 2001
From: mstackhouse
-t <- tplyr_table(adsl, TRT01P) %>%
+t <- tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(AGEGR1, by = "Age categories n (%)")
)
-t <- tplyr_table(adsl, TRT01P) %>%
+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)) %>%
@@ -347,7 +347,7 @@ Adding Layers to a Table
-t <- tplyr_table(adsl, TRT01P)
+t <- tplyr_table(tplyr_adsl, TRT01P)
l1 <- group_count(t, AGEGR1, by = "Age categories n (%)")
l2 <- group_desc(t, AGE, by = "Age (years)")
@@ -377,7 +377,7 @@ A Note Before We Go DeeperTo generate the data from a tplyr_table()
object, you
use the function build()
:
-t <- tplyr_table(adsl, TRT01P) %>%
+t <- tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(AGEGR1, by = "Age categories n (%)")
)
@@ -584,7 +584,7 @@ String Formatting in Tplyr<
So - why is this object necessary. Consider this example:
-t <- tplyr_table(adsl, TRT01P) %>%
+t <- tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_desc(AGE, by = "Age (years)") %>%
set_format_strings(
@@ -697,7 +697,7 @@ String Formatting in Tplyr<
with specifying a distinct_by()
variable using
set_distinct_by()
.
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(AGEGR1, by = "Age categories") %>%
set_format_strings(f_str('xx (xx.x)',n,pct))
@@ -760,7 +760,7 @@ String Formatting in Tplyr<
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(AGEGR1, by = "Age categories") %>%
set_format_strings(f_str('xx',n))
@@ -824,7 +824,7 @@ String Formatting in Tplyr<
Really - format strings allow you to present your data however you
like.
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(AGEGR1, by = "Age categories") %>%
set_format_strings(f_str('xx (•◡•) xx.x%',n,pct))
@@ -899,7 +899,7 @@ Descriptive Statistic Layers
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_desc(AGE, by = "Age (years)")
) %>%
@@ -996,7 +996,7 @@ Descriptive Statistic Layersset_custom_summaries()
comes into play. Let’s say you want to derive a geometric mean.
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_desc(AGE, by = "Sepal Length") %>%
set_custom_summaries(
@@ -1052,7 +1052,7 @@ Descriptive Statistic Layers
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_desc(vars(AGE, AVGDD), by = "Age and Avg. Daily Dose")
) %>%
@@ -1182,7 +1182,7 @@ Count Layersadd_total_row()
:
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(AGEGR1, by = "Age categories") %>%
add_total_row()
@@ -1257,7 +1257,7 @@ Count Layersset_distinct_by()
:
-tplyr_table(adae, TRTA) %>%
+tplyr_table(tplyr_adae, TRTA) %>%
add_layer(
group_count('Subjects with at least one adverse event') %>%
set_distinct_by(USUBJID) %>%
@@ -1300,7 +1300,7 @@ Count Layers
-tplyr_table(adae, TRTA) %>%
+tplyr_table(tplyr_adae, TRTA) %>%
add_layer(
group_count(vars(AEBODSYS, AEDECOD))
) %>%
@@ -1410,10 +1410,10 @@ Shift Layers
# Tplyr can use factor orders to dummy values and order presentation
-adlb$ANRIND <- factor(adlb$ANRIND, c("L", "N", "H"))
-adlb$BNRIND <- factor(adlb$BNRIND, c("L", "N", "H"))
+tplyr_adlb$ANRIND <- factor(tplyr_adlb$ANRIND, c("L", "N", "H"))
+tplyr_adlb$BNRIND <- factor(tplyr_adlb$BNRIND, c("L", "N", "H"))
-tplyr_table(adlb, TRTA, where = PARAMCD == "CK") %>%
+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))
diff --git a/articles/count.html b/articles/count.html
index 37175ee3..49270051 100644
--- a/articles/count.html
+++ b/articles/count.html
@@ -44,7 +44,7 @@
Tplyr
- 1.1.0
+ 1.2.1
@@ -142,7 +142,7 @@ A Simple Example
-t <- tplyr_table(adsl, TRT01P, where = SAFFL == "Y") %>%
+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(
@@ -270,7 +270,7 @@ Distinct Versus Event Counts
-t <- tplyr_table(adae, TRTA) %>%
+t <- tplyr_table(tplyr_adae, TRTA) %>%
add_layer(
group_count(AEDECOD) %>%
set_distinct_by(USUBJID) %>%
@@ -362,7 +362,7 @@ Distinct Versus Event Counts
-t <- tplyr_table(adae, TRTA) %>%
+t <- tplyr_table(tplyr_adae, TRTA) %>%
add_layer(
group_count(AEDECOD) %>%
set_distinct_by(USUBJID) %>%
@@ -414,7 +414,7 @@ Nested Count Summariesrow_label2
changes. These are the summaries for
AEDECOD
.
-tplyr_table(adae, TRTA) %>%
+tplyr_table(tplyr_adae, TRTA) %>%
add_layer(
group_count(vars(AEBODSYS, AEDECOD))
) %>%
@@ -509,7 +509,7 @@ Nested Count Summaries
-tplyr_table(adae, TRTA) %>%
+tplyr_table(tplyr_adae, TRTA) %>%
add_layer(
group_count(vars(AEBODSYS, AEDECOD)) %>%
set_nest_count(TRUE) %>%
diff --git a/articles/custom-metadata.html b/articles/custom-metadata.html
index 4b51a1b8..f6245d17 100644
--- a/articles/custom-metadata.html
+++ b/articles/custom-metadata.html
@@ -44,7 +44,7 @@
Tplyr
- 1.1.0
+ 1.2.1
@@ -354,9 +354,9 @@ Build a tplyr_meta
objectm
#> tplyr_meta: 3 names, 3 filters
#> Names:
-#> a, b, c
+#> a, b, c
#> Filters:
-#> a == 1, b == 2, c == 3
+#> a == 1, b == 2, c == 3
The tplyr_meta()
function can take these fields
immediately upon creation. If you need to dynamically create a
tplyr_meta
object such as how Tplyr
@@ -371,9 +371,9 @@
Build a tplyr_meta
objectm
#> tplyr_meta: 4 names, 4 filters
#> Names:
-#> a, b, c, x
+#> a, b, c, x
#> Filters:
-#> a == 1, b == 2, c == 3, x == "a"
+#> a == 1, b == 2, c == 3, x == "a"
Building your own metadata table
@@ -447,6 +447,39 @@ Building your own metadata table
+
+Anti-joins
+
+If the custom metadata you’re constructing requires references to
+data outside your target dataset, this is also possible with a
+tplyr_meta
object. If you’re looking for non-overlap with
+the target dataset, you can use an anti-join. Anti-joins can be added to
+a tplyr_meta
object using the add_anti_join()
+function.
+
+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
+
Appending Existing Tplyr Metadata
@@ -455,13 +488,13 @@ Appending Existing TplyrTplyr metadata, let’s extend the existing data frame.
To do this, Tplyr has the function
append_metadata()
:
-
+
t <- append_metadata(t, eff_meta)
Behind the scenes, this function simply binds the new metadata with
the old in the proper section of the tplyr_table
object.
You can view the the tplyr_table
metadata with the function
get_metadata()
:
-
+
get_metadata(t)
#> # A tibble: 16 × 6
#> row_id row_label1 row_label2 var1_Placebo var1_Xanomeline High…¹
@@ -486,7 +519,7 @@ Appending Existing Tplyr#> # ℹ 1 more variable: `var1_Xanomeline Low Dose` <list>
Finally, as with the automatically created metadata from Tplyr, we
can query these result cells just the same:
-
+
get_meta_subset(t, 'x4_1', "var1_Xanomeline High Dose") %>%
head() %>%
kable()
@@ -615,8 +648,8 @@ Metadata Without TplyrTplyr table, and parameters to provide
your own target data frame:
-
-get_meta_subset(eff_meta, 'x4_1', "var1_Xanomeline High Dose", target=adas) %>%
+
+get_meta_subset(eff_meta, 'x4_1', "var1_Xanomeline High Dose", target=tplyr_adas) %>%
head() %>%
kable()
diff --git a/articles/denom.html b/articles/denom.html
index 05ada6e1..0ec125fb 100644
--- a/articles/denom.html
+++ b/articles/denom.html
@@ -44,7 +44,7 @@
Tplyr
- 1.1.0
+ 1.2.1
@@ -156,7 +156,7 @@ Population Data in the Denominator
Consider these two examples.
-tplyr_table(adae, TRTA) %>%
+tplyr_table(tplyr_adae, TRTA) %>%
add_layer(
group_count(AEDECOD) %>%
set_distinct_by(USUBJID) %>%
@@ -234,8 +234,8 @@ Population Data in the Denominator
-tplyr_table(adae, TRTA) %>%
- set_pop_data(adsl) %>%
+tplyr_table(tplyr_adae, TRTA) %>%
+ set_pop_data(tplyr_adsl) %>%
set_pop_treat_var(TRT01A) %>%
add_layer(
group_count(AEDECOD) %>%
@@ -351,10 +351,10 @@ Count layers
-adsl <- adsl %>%
+tplyr_adsl <- tplyr_adsl %>%
mutate(DCSREAS = ifelse(DCSREAS == '', 'Completed', DCSREAS))
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(DCSREAS)
) %>%
@@ -465,7 +465,7 @@ Count layers
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(DCSREAS, by=SEX)
) %>%
@@ -701,7 +701,7 @@ Count layersset_denoms_by()
.
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(DCSREAS, by=SEX) %>%
set_denoms_by(SEX, TRT01P)
@@ -957,7 +957,7 @@ Shift layers
-tplyr_table(adlb, TRTA, where=PARAMCD == "CK") %>%
+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)) %>%
@@ -1101,7 +1101,7 @@ Shift layers
-tplyr_table(adlb, TRTA, where=PARAMCD == "CK") %>%
+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)) %>%
@@ -1241,7 +1241,7 @@ Shift layers
-tplyr_table(adlb, TRTA, where = PARAMCD == "CK") %>%
+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)) %>%
@@ -1416,10 +1416,10 @@ Controlling the Denominator Filter. This is important - this allows the percentages from Layer 3
to sum to the total percentage of “DISCONTINUED” from Layer 1.
-adsl2 <- adsl %>%
+tplyr_adsl2 <- tplyr_adsl %>%
mutate(DISCONTEXT = if_else(DISCONFL == 'Y', 'DISCONTINUED', 'COMPLETED'))
-t <- tplyr_table(adsl2, TRT01P, where = SAFFL == 'Y') %>%
+t <- tplyr_table(tplyr_adsl2, TRT01P, where = SAFFL == 'Y') %>%
add_layer(
group_count(DISCONTEXT)
) %>%
@@ -1644,10 +1644,10 @@ Missing Counts
-adae2 <- adae
-adae2[sample(nrow(adae2), 50), "AESEV"] <- NA
+tplyr_adae2 <- tplyr_adae
+tplyr_adae2[sample(nrow(tplyr_adae2), 50), "AESEV"] <- NA
-t <- tplyr_table(adae2, TRTA) %>%
+t <- tplyr_table(tplyr_adae2, TRTA) %>%
add_layer(
group_count(AESEV) %>%
set_format_strings(f_str("xxx (xx.xx%)", n, pct)) %>%
@@ -1678,33 +1678,33 @@ Missing Counts
MILD
-23 (58.97%)
-69 (74.19%)
-41 (43.62%)
+21 (55.26%)
+70 (76.09%)
+46 (47.92%)
1
1
MODERATE
-16 (41.03%)
-23 (24.73%)
-48 (51.06%)
+17 (44.74%)
+21 (22.83%)
+46 (47.92%)
1
2
SEVERE
0 ( 0.00%)
-1 ( 1.08%)
-5 ( 5.32%)
+1 ( 1.09%)
+4 ( 4.17%)
1
3
Missing
-8
-18
-24
+9
+19
+22
1
Inf
@@ -1720,6 +1720,102 @@ Missing Counts
+Missing Subjects
+
+Missing counts and counting missing subjects work two different ways
+within Tplyr. Missing counts, as described above, will examine the
+records present in the data and collect and missing values. But for
+these results to be counted, they need to first be provided within the
+input data itself. On the other hand, missing subjects are calculated by
+looking at the difference between the potential number of subjects
+within the column (i.e. the combination of the treatment variables and
+column variables) and the number of subjects actually present. Consider
+this example:
+
+ 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()
+
+
+
+
+
+
+
+
+row_label1
+var1_Placebo
+var1_Xanomeline High Dose
+var1_Xanomeline Low Dose
+
+
+
+SKIN EXFOLIATION
+0 ( 0.0%)
+0 ( 0.0%)
+1 ( 1.2%)
+
+
+SKIN IRRITATION
+3 ( 3.5%)
+5 ( 6.0%)
+6 ( 7.1%)
+
+
+SKIN ODOUR ABNORMAL
+0 ( 0.0%)
+1 ( 1.2%)
+0 ( 0.0%)
+
+
+SKIN ULCER
+1 ( 1.2%)
+0 ( 0.0%)
+0 ( 0.0%)
+
+
+URTICARIA
+0 ( 0.0%)
+1 ( 1.2%)
+1 ( 1.2%)
+
+
+Missing Subjects
+65 ( 75.6%)
+42 ( 50.0%)
+42 ( 50.0%)
+
+
+
+In the example above, we produce a nested count layer. The function
+add_missing_subjects_row()
triggers the addition of the new
+result row for which the missing subjects are calculated. The row label
+applied for this can be configured using
+set_missing_subjects_row_label()
, and the row label itself
+will default to ‘Missing’. Depending on your sorting needs, a
+sort_value
can be applied to whatever numeric value you
+provide. Lastly, you can provide an f_str()
to format the
+missing subjects row separately from the rest of the layer, but whatever
+format is applied to the layer will apply otherwise.
+Note that in nested count layers, missing subject rows will generate
+for each independent group within the outer layer. Outer layers cannot
+have missing subject rows calculated individually. This would best be
+done in an independent layer itself, as the result would apply to the
+whole input target dataset.
+
+
Adding a ‘Total’ Row
In addition to missing counts, some summaries require the addition of
@@ -1762,11 +1858,11 @@
Adding a ‘Total’ RowTplyr.
-
-adsl2 <- adsl
-adsl2[sample(nrow(adsl2), 50), "AGEGR1"] <- NA
+
+tplyr_adsl2 <- tplyr_adsl
+tplyr_adsl2[sample(nrow(tplyr_adsl2), 50), "AGEGR1"] <- NA
-tplyr_table(adsl2, TRT01P) %>%
+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
@@ -1812,9 +1908,9 @@ Adding a ‘Total’ Row
F
<65
-6 ( 11.3%)
-2 ( 5.0%)
-4 ( 8.0%)
+8 ( 15.1%)
+5 ( 12.5%)
+5 ( 10.0%)
1
1
1
@@ -1822,9 +1918,9 @@ Adding a ‘Total’ Row
F
>80
-18 ( 34.0%)
+19 ( 35.8%)
7 ( 17.5%)
-14 ( 28.0%)
+13 ( 26.0%)
1
1
2
@@ -1832,9 +1928,9 @@ Adding a ‘Total’ Row
F
65-80
-17 ( 32.1%)
-22 ( 55.0%)
-22 ( 44.0%)
+13 ( 24.5%)
+24 ( 60.0%)
+24 ( 48.0%)
1
1
3
@@ -1842,9 +1938,9 @@ Adding a ‘Total’ Row
F
Missing
-12 (22.6%)
-9 (22.5%)
-10 (20.0%)
+13 (24.5%)
+4 (10.0%)
+8 (16.0%)
1
1
Inf
@@ -1863,7 +1959,7 @@ Adding a ‘Total’ RowM
<65
5 ( 15.2%)
-5 ( 11.4%)
+2 ( 4.5%)
2 ( 5.9%)
1
2
@@ -1873,7 +1969,7 @@ Adding a ‘Total’ RowM
>80
7 ( 21.2%)
-9 ( 20.5%)
+6 ( 13.6%)
11 ( 32.4%)
1
2
@@ -1882,9 +1978,9 @@ Adding a ‘Total’ Row
M
65-80
-17 ( 51.5%)
-22 ( 50.0%)
-14 ( 41.2%)
+16 ( 48.5%)
+21 ( 47.7%)
+16 ( 47.1%)
1
2
3
@@ -1892,9 +1988,9 @@ Adding a ‘Total’ Row
M
Missing
-4 (12.1%)
-8 (18.2%)
-7 (20.6%)
+5 (15.2%)
+15 (34.1%)
+5 (14.7%)
1
2
Inf
@@ -1908,8 +2004,8 @@ Adding a ‘Total’ Rowset_missing_count()
. So more commonly,
you’ll see this:
-
-tplyr_table(adsl2, TRT01P) %>%
+
+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
@@ -1945,9 +2041,9 @@ Adding a ‘Total’ Row
F
All Age Groups
-41
-31
40
+36
+42
1
1
-Inf
@@ -1955,9 +2051,9 @@ Adding a ‘Total’ Row
F
<65
-6 ( 14.6%)
-2 ( 6.5%)
-4 ( 10.0%)
+8 ( 20.0%)
+5 ( 13.9%)
+5 ( 11.9%)
1
1
1
@@ -1965,9 +2061,9 @@ Adding a ‘Total’ Row
F
>80
-18 ( 43.9%)
-7 ( 22.6%)
-14 ( 35.0%)
+19 ( 47.5%)
+7 ( 19.4%)
+13 ( 31.0%)
1
1
2
@@ -1975,9 +2071,9 @@ Adding a ‘Total’ Row
F
65-80
-17 ( 41.5%)
-22 ( 71.0%)
-22 ( 55.0%)
+13 ( 32.5%)
+24 ( 66.7%)
+24 ( 57.1%)
1
1
3
@@ -1985,9 +2081,9 @@ Adding a ‘Total’ Row
F
Missing
-12
-9
-10
+13
+4
+8
1
1
Inf
@@ -1995,9 +2091,9 @@ Adding a ‘Total’ Row
M
All Age Groups
+28
+29
29
-36
-27
1
2
-Inf
@@ -2005,9 +2101,9 @@ Adding a ‘Total’ Row
M
<65
-5 ( 17.2%)
-5 ( 13.9%)
-2 ( 7.4%)
+5 ( 17.9%)
+2 ( 6.9%)
+2 ( 6.9%)
1
2
1
@@ -2015,9 +2111,9 @@ Adding a ‘Total’ Row
M
>80
-7 ( 24.1%)
-9 ( 25.0%)
-11 ( 40.7%)
+7 ( 25.0%)
+6 ( 20.7%)
+11 ( 37.9%)
1
2
2
@@ -2025,9 +2121,9 @@ Adding a ‘Total’ Row
M
65-80
-17 ( 58.6%)
-22 ( 61.1%)
-14 ( 51.9%)
+16 ( 57.1%)
+21 ( 72.4%)
+16 ( 55.2%)
1
2
3
@@ -2035,9 +2131,9 @@ Adding a ‘Total’ Row
M
Missing
-4
-8
-7
+5
+15
+5
1
2
Inf
diff --git a/articles/desc.html b/articles/desc.html
index c0e14334..4e387691 100644
--- a/articles/desc.html
+++ b/articles/desc.html
@@ -44,7 +44,7 @@
Tplyr
- 1.1.0
+ 1.2.1
@@ -133,7 +133,7 @@ Post-processing
set_format_strings()
where the actual summaries are
declared.
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_desc(AGE, by = "Age (years)", where= SAFFL=="Y") %>%
set_format_strings(
@@ -346,10 +346,20 @@ Built-in SummariesNotes About Built-in’s
Note that the only non-default option being used in any of the
-function calls above is na.rm=TRUE
. For most of the
-functions, this is likely fine - but with IQR, Q1, and Q3 note that
-there are several different quantile algorithms available in R. The
-default we chose to use is the R default of Type 7:
+function calls above is na.rm=TRUE
. It’s important to note
+that for min
and max
, when
+na.rm=TRUE
is used with a vector that is all
+NA
, these functions return Inf
and
+-Inf
respectively. When formatting the numbers, this is
+unexpected and also inconsistent with how other descriptive statistic
+functions, which return NA
. Therefore, just for
+min
and max
, Inf
’s are converted
+to NA
so that they’ll align with the behavior of the
+empty
parameter in f_str()
.
+Using default settings of most descriptive statistic functions is
+typically fine, but with IQR, Q1, and Q3 note that there are several
+different quantile algorithms available in R. The default we chose to
+use is the R default of Type 7:
\[
m = 1-p. p[k] = (k - 1) / (n - 1). \textrm{In this case, } p[k] =
mode[F(x[k])]. \textrm{This is used by S.}
@@ -361,7 +371,7 @@ Notes About Built-in’sThe example below demonstrates using the default quantile algorithm
in R.
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_desc(CUMDOSE) %>%
set_format_strings("Q1, Q3" = f_str('xxxxx, xxxxx', q1, q3))
@@ -397,7 +407,7 @@ Notes About Built-in’s
options(tplyr.quantile_type = 3)
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_desc(CUMDOSE) %>%
set_format_strings("Q1, Q3" = f_str('xxxxx, xxxxx', q1, q3))
@@ -454,7 +464,7 @@ Custom Summaries
Let’s look at an example.
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_desc(vars(AGE, HEIGHTBL), by = "Sepal Length") %>%
set_custom_summaries(
@@ -525,7 +535,7 @@ Custom Summaries
For example, here we use the Tplyr default mean.
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_desc(AGE) %>%
set_format_strings("Mean" = f_str('xx.xx', mean))
@@ -568,7 +578,7 @@ Custom Summaries )
)
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_desc(AGE) %>%
set_format_strings("Mean" = f_str('xx.xx', mean))
diff --git a/articles/desc_layer_formatting.html b/articles/desc_layer_formatting.html
index 05d89f6b..1890100a 100644
--- a/articles/desc_layer_formatting.html
+++ b/articles/desc_layer_formatting.html
@@ -44,7 +44,7 @@
Tplyr
- 1.1.0
+ 1.2.1
@@ -140,14 +140,14 @@ Empty Value Formatting
-adsl$TRT01P <- as.factor(adsl$TRT01P)
-adlb$TRTA <- as.factor(adlb$TRTA)
+tplyr_adsl$TRT01P <- as.factor(tplyr_adsl$TRT01P)
+tplyr_adlb$TRTA <- as.factor(tplyr_adlb$TRTA)
-adlb_2 <- adlb %>%
+tplyr_adlb_2 <- tplyr_adlb %>%
filter(TRTA != "Placebo")
-tplyr_table(adlb_2, TRTA) %>%
- set_pop_data(adsl) %>%
+tplyr_table(tplyr_adlb_2, TRTA) %>%
+ set_pop_data(tplyr_adsl) %>%
set_pop_treat_var(TRT01P) %>%
add_layer(
group_desc(AVAL, by=PARAMCD) %>%
@@ -216,8 +216,8 @@ Empty Value Formattingf_str()
object using the empty
parameter.
-tplyr_table(adlb_2, TRTA) %>%
- set_pop_data(adsl) %>%
+tplyr_table(tplyr_adlb_2, TRTA) %>%
+ set_pop_data(tplyr_adsl) %>%
set_pop_treat_var(TRT01P) %>%
add_layer(
group_desc(AVAL, by=PARAMCD) %>%
@@ -287,8 +287,8 @@ Empty Value Formatting
-tplyr_table(adlb_2, TRTA) %>%
- set_pop_data(adsl) %>%
+tplyr_table(tplyr_adlb_2, TRTA) %>%
+ set_pop_data(tplyr_adsl) %>%
set_pop_treat_var(TRT01P) %>%
add_layer(
group_desc(AVAL, by=PARAMCD) %>%
@@ -378,7 +378,7 @@ Auto Precisionn
is the number of additional spaces you wish to
add.
-tplyr_table(adlb, TRTA) %>%
+tplyr_table(tplyr_adlb, TRTA) %>%
add_layer(
group_desc(AVAL, by = PARAMCD) %>%
set_format_strings(
@@ -455,7 +455,7 @@ Auto Precision
-tplyr_table(adlb, TRTA) %>%
+tplyr_table(tplyr_adlb, TRTA) %>%
add_layer(
group_desc(AVAL, by = PARAMCD) %>%
set_format_strings(
@@ -540,7 +540,7 @@ Auto Precision
-tplyr_table(adlb, TRTA) %>%
+tplyr_table(tplyr_adlb, TRTA) %>%
add_layer(
group_desc(vars(AVAL, CHG, BASE), by = PARAMCD) %>%
set_format_strings(
@@ -686,7 +686,7 @@ External Precision"URATE", 3, 1,
)
-tplyr_table(adlb, TRTA) %>%
+tplyr_table(tplyr_adlb, TRTA) %>%
add_layer(
group_desc(AVAL, by = PARAMCD) %>%
set_format_strings(
@@ -765,7 +765,7 @@ External Precision"GGT", 3, 0,
)
-tplyr_table(adlb, TRTA) %>%
+tplyr_table(tplyr_adlb, TRTA) %>%
add_layer(
group_desc(AVAL, by = PARAMCD) %>%
set_format_strings(
@@ -841,7 +841,7 @@ Parenthesis Hugging
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_desc(AGE, by = "Age (years)", where= SAFFL=="Y") %>%
set_format_strings(
@@ -874,7 +874,7 @@ Parenthesis Hugging
-tplyr_table(adlb, TRTA, PARAMCD == "CK") %>%
+tplyr_table(tplyr_adlb, TRTA, PARAMCD == "CK") %>%
add_layer(
group_desc(AVAL, by=vars(PARAMCD, AVISIT)) %>%
set_format_strings(
@@ -895,7 +895,7 @@ Parenthesis Hugging
-tplyr_table(adlb, TRTA, PARAMCD == "CK") %>%
+tplyr_table(tplyr_adlb, TRTA, PARAMCD == "CK") %>%
add_layer(
group_desc(AVAL, by=vars(PARAMCD, AVISIT)) %>%
set_format_strings(
diff --git a/articles/general_string_formatting.html b/articles/general_string_formatting.html
index 3cc67166..de021d9e 100644
--- a/articles/general_string_formatting.html
+++ b/articles/general_string_formatting.html
@@ -44,7 +44,7 @@
Tplyr
- 1.1.0
+ 1.2.1
@@ -146,7 +146,7 @@ Format Strings
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(RACE) %>%
set_format_strings(
@@ -384,7 +384,7 @@ Lowercase ‘x’var1_Placebo
row below.
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(RACE) %>%
set_format_strings(
@@ -410,7 +410,7 @@ Lowercase ‘x’
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(RACE) %>%
set_format_strings(
@@ -438,7 +438,7 @@ Uppercase ‘X’
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(RACE) %>%
set_format_strings(
@@ -475,7 +475,7 @@ Auto-precision
Consider the following example.
-tplyr_table(adlb, TRTA, where=PARAMCD %in% c("CA", "URATE")) %>%
+tplyr_table(tplyr_adlb, TRTA, where=PARAMCD %in% c("CA", "URATE")) %>%
add_layer(
group_desc(AVAL, by=vars(PARAMCD, AVISIT)) %>%
set_format_strings(
@@ -506,7 +506,7 @@ Auto-precisionn
result based on the maximum
summarized value of n
within the data. For example:
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
group_count(RACE) %>%
set_format_strings(f_str("a (xxx.x%)", n, pct))
@@ -527,8 +527,8 @@ Auto-precisionX
, but is triggered using auto-precision. Take this
example of an adverse event table:
-tplyr_table(adae, TRTA) %>%
- set_pop_data(adsl) %>%
+tplyr_table(tplyr_adae, TRTA) %>%
+ set_pop_data(tplyr_adsl) %>%
set_pop_treat_var(TRT01A) %>%
add_layer(
group_count(AEDECOD) %>%
diff --git a/articles/index.html b/articles/index.html
index 8cec9eef..4b2f856a 100644
--- a/articles/index.html
+++ b/articles/index.html
@@ -16,7 +16,7 @@
Tplyr
- 1.1.0
+ 1.2.1
diff --git a/articles/layer_templates.html b/articles/layer_templates.html
index a6e3cd1c..2723ac67 100644
--- a/articles/layer_templates.html
+++ b/articles/layer_templates.html
@@ -44,7 +44,7 @@
Tplyr
- 1.1.0
+ 1.2.1
@@ -178,7 +178,7 @@ Basic Templates
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
use_template("example_template", RACE, by=ETHNIC)
) %>%
@@ -281,7 +281,7 @@ Basic TemplatesTplyr table. For example:
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
use_template("example_template", RACE) %>%
add_total_row()
@@ -374,7 +374,7 @@ Templates With Parametersuse_template()
argument add_params
. For
example:
-tplyr_table(adsl, TRT01P) %>%
+tplyr_table(tplyr_adsl, TRT01P) %>%
add_layer(
use_template('example_params', RACE, add_params =
list(
diff --git a/articles/metadata.html b/articles/metadata.html
index f99aaf1e..a9536cf8 100644
--- a/articles/metadata.html
+++ b/articles/metadata.html
@@ -44,7 +44,7 @@
Tplyr
- 1.1.0
+ 1.2.1
@@ -154,7 +154,7 @@ Generating the Metadata
Consider the following example:
-