Skip to content

Issue with strata in g__lineplot() #664

@qiliu1013

Description

@qiliu1013

g_lineplot() is re-setting the factor level in strata.

adsl <- scda::synthetic_cdisc_data("latest")$adsl
adlb <- scda::synthetic_cdisc_data("latest")$adlb
adlb <- dplyr::filter(adlb, ANL01FL == "Y", PARAMCD == "ALT", AVISIT != "SCREENING")
adlb$AVISIT <- droplevels(adlb$AVISIT)
adlb <- dplyr::mutate(adlb, AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min))
unique(adlb$ARM)
[1] A: Drug X      C: Combination B: Placebo    
Levels: A: Drug X B: Placebo C: Combination

adlb <- adlb %>% mutate(ARM1 = factor(ARM, levels = c("B: Placebo", "C: Combination", "A: Drug X")))
unique(adlb$ARM1)
[1] A: Drug X      C: Combination B: Placebo    
Levels: B: Placebo C: Combination A: Drug X

 tern::g_lineplot(
     adlb, strata = ARM,
     whiskers = "mean_ci_upr",
     title = "Plot of Mean and Upper 95% Confidence Limit by Visit"
 )

tern::g_lineplot(
     adlb, strata = ARM1,
     whiskers = "mean_ci_upr",
     title = "Plot of Mean and Upper 95% Confidence Limit by Visit"
 )

The level of ARM and ARM1 are different, but the outputs are the same.

Screen Shot 2022-08-04 at 11 29 24 AM

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingsme

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions