You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm attempting to use Tplyr to compute a group_count layer that I'm not sure how to specify. To give some background, I've simulated a partial adae table below that has USUBJID, ARM and AETOXGRN. AETOXGRN is a toxicity grading used frequently within Oncology and ranges from 1 to 5.
What I'm interested in counting is each subjects worst (i.e. highest) toxicity grades. I'm interested in distinct counts, so for example, if subject X had two AEs, one graded with AETOXGRN = 1, and another with AETOXGRN = 4, I'd like this subject to be counted in the "4" category only.
I can achieve this in dplyr, and also achieve this in Tplyr with some up-front filtering. However, I'm wondering if I can specify something like this directly in Tplyr.
# Using Tplyr
t <- tplyr_table(adae, ARM) %>%
add_layer(
group_count(AETOXGRN, where = AETOXGRN == max(AETOXGRN)) %>%
set_distinct_by(USUBJID)
)
t %>% build()
# Tplyr output
# A tibble: 1 x 5
# row_label1 var1_Placebo var1_Treatment ord_layer_index ord_layer_1
# <chr> <chr> <chr> <int> <dbl>
# 5 1 (100.0%) 1 (100.0%) 1 5
I can see that Tplyr only outputs the result for the max(AETOXGRN) grade, 5, which looks correct. So it seems my filter is acting on a data set level rather than a per USUBJID level. Is there a good way to specify a where filter of this nature or have I maybe missed other options in Tplyr?
Curious to hear any thoughts!
Thanks!
Matt
The text was updated successfully, but these errors were encountered:
Currently this wouldn't be possible because we don't really have a clean way to make groups pass down into where filter conditions are applied. We didn't really plan for that so it would take a good bit of thought for how to do it elegantly. Like I'm almost thinking that it would be safer to pre-derive a flag and use the flag, which is how ADaM datasets would typically set things up. Because grouping and ungrouping here is a bit tricky.
Hi guys,
I'm attempting to use Tplyr to compute a group_count layer that I'm not sure how to specify. To give some background, I've simulated a partial adae table below that has USUBJID, ARM and AETOXGRN. AETOXGRN is a toxicity grading used frequently within Oncology and ranges from 1 to 5.
What I'm interested in counting is each subjects worst (i.e. highest) toxicity grades. I'm interested in distinct counts, so for example, if subject X had two AEs, one graded with AETOXGRN = 1, and another with AETOXGRN = 4, I'd like this subject to be counted in the "4" category only.
I can achieve this in dplyr, and also achieve this in Tplyr with some up-front filtering. However, I'm wondering if I can specify something like this directly in Tplyr.
Here is some code for my exploration.
I can see that Tplyr only outputs the result for the max(AETOXGRN) grade, 5, which looks correct. So it seems my filter is acting on a data set level rather than a per USUBJID level. Is there a good way to specify a
where
filter of this nature or have I maybe missed other options in Tplyr?Curious to hear any thoughts!
Thanks!
Matt
The text was updated successfully, but these errors were encountered: