insightsengineering / tlg-catalog

A catalog of Tables, Listings and Graphs (TLGs) created with NEST R packages
https://insightsengineering.github.io/tlg-catalog/
Other
20 stars 8 forks source link

counts for pkcg03 plot should be per cohorts #131

Closed Melkiades closed 1 year ago

Melkiades commented 1 year ago

Discussed in https://github.com/insightsengineering/tlg-catalog/discussions/130

Originally posted by **giscus[bot]** September 22, 2023 # tlg-catalog/graphs/pharmacokinetic/pkcg03 Plot of Mean PK Concentration Over Time by Cohort https://insightsengineering.github.io/tlg-catalog/graphs/pharmacokinetic/pkcg03.html
legrasv commented 1 year ago

A bit of code to help:

I had to hardcode the function g_lineplot it for one of my TLGs:

# df_N <- as.data.frame(table(alt_counts_df[[strata]], exclude = c(NA, NaN, Inf))) # nolint
df_N <- aggregate(USUBJID ~ eval(parse(text = strata)), data = alt_counts_df, FUN = function(x) length(unique(x))) # nolint

knowing that USUBJID has to be defined in the parameters of the function somehow

Melkiades commented 1 year ago

A bit of code to help:

I had to hardcode the function g_lineplot it for one of my TLGs:

# df_N <- as.data.frame(table(alt_counts_df[[strata]], exclude = c(NA, NaN, Inf))) # nolint
df_N <- aggregate(USUBJID ~ eval(parse(text = strata)), data = alt_counts_df, FUN = function(x) length(unique(x))) # nolint

knowing that USUBJID has to be defined in the parameters of the function somehow

@ayogasekaram could you take a look at this, please? Thank you!!! :)

legrasv commented 1 year ago

@ayogasekaram Actually on this plot, there is something else that is wrong:

image

It does not link all the points (because of the different nominal time that we have between the Treatment groups).

So I could also fix it myself by adding in g_lineplot : df_stats <- df_stats[!is.na(df_stats$mean),] ## could be coded in dplyr as well

before the line of code:

legrasv commented 1 year ago

Result:

image
ayogasekaram commented 1 year ago

thank you @legrasv for your code suggestions! I believe your second suggestion is already implemented in g_lineplot here. the default for the mid variable is "mean" which is identical to the line of code you have above.

legrasv commented 1 year ago

Sounds good thank you @ayogasekaram