Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plotgsPower() to use offset arg for Future Analysis legend #121

Merged
merged 3 commits into from
Feb 7, 2024

Conversation

jdblischak
Copy link
Contributor

I changed the legend title from Analysis to Future Analysis. I did this by directly updating the column name in the underlying data that is passed to {ggplot2}. An alternative would be to keep the column name as Analysis and only change the legend title. Please let me know if that would be preferred.

I also added an argument offset to add an arbitrary integer value to the Future Analysis legend labels. I added a roxygen2 @param for this argument, but it's not being used. AFAICT there is no man page for plotgsPower(), but I am not familiar with {sinew}

Demonstration

library("gsDesign")
x <- gsDesign(test.type = 1, delta1 = 0.3, sfu = sfLDOF)

# Future Analysis: 1, 2, 3
gsDesign:::plotgsPower(x)

# Future Analysis: 2, 3, 4
gsDesign:::plotgsPower(x, offset = 1)

image

image

@jdblischak
Copy link
Contributor Author

cc @keaven @nanxstats

@jdblischak
Copy link
Contributor Author

Here is how to recreate the above plots without directly accessing the internal function via ::::

library("gsDesign")
x <- gsDesign(test.type = 1, delta1 = 0.3, sfu = sfLDOF)

# Future Analysis: 1, 2, 3
plot(x, plottype = 2)

# Future Analysis: 2, 3, 4
plot(x, plottype = 2, offset = 1)

@jdblischak
Copy link
Contributor Author

I've enabled the following behavior for the legend title:

  • Default to "Analysis"
  • If offset > 0, default to "Future Analysis"
  • Either of the above defaults can be overridden by passing the argument titleAnalysisCustom (Note: I can change the formatting of this variable name. I couldn't figure out the style from the file. Most of the variable names are single words, so I didn't know how to name a multi-word variable. I went with camelCase, but I can switch to whatever)

Here is some example code to demonstrate the latest behavior:

library("gsDesign")
x <- gsDesign(test.type = 1, delta1 = 0.3, sfu = sfLDOF)

# Analysis: 1, 2, 3
plot(x, plottype = 2)

# Future Analysis: 2, 3, 4
plot(x, plottype = 2, offset = 1)

# Custom label: 2, 3, 4
plot(x, plottype = 2, offset = 1, titleAnalysisCustom = "A custom label")

@keaven keaven merged commit 7b55f56 into keaven:master Feb 7, 2024
9 checks passed
@jdblischak jdblischak deleted the plotgspower-offset branch February 7, 2024 21:31
@jdblischak jdblischak mentioned this pull request Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants