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

reconciling cran-fixes with main: autoplot.curve_params #254

Merged
merged 8 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: serocalculator
Type: Package
Title: Estimating Infection Rates from Serological Data
Version: 1.2.0.9001
Version: 1.2.0.9002
Authors@R: c(
person(given = "Peter", family = "Teunis", email = "[email protected]", role = c("aut", "cph"), comment = "Author of the method and original code."),
person(given = "Kristina", family = "Lai", email = "[email protected]", role = c("aut", "cre")),
Expand Down
25 changes: 17 additions & 8 deletions R/autoplot.curve_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,37 @@
#'
#' @inheritParams plot_curve_params_one_ab
#' @inheritDotParams plot_curve_params_one_ab
#' @param antigen_isos antigen isotypes to analyze (can be used to subset `curve_params`)
#' @param antigen_isos antigen isotypes to analyze (can subset `curve_params`)
#' @param ncol how many columns of subfigures to use in panel plot
#' @details
#' ## `rows_to_graph`
#' Note that if you directly specify `rows_to_graph` when calling this function, the row numbers are enumerated separately for each antigen isotype; in other words, for the purposes of this argument, row numbers start over at 1 for each antigen isotype. There is currently no way to specify different row numbers for different antigen isotypes; if you want to do that, you will could call [plot_curve_params_one_ab()] directly for each antigen isotype and combine the resulting panels yourself. Or you could subset `curve_params` manually, before passing it to this function, and set the `n_curves` argument to `Inf`.
#' Note that if you directly specify `rows_to_graph` when calling this function,
#' the row numbers are enumerated separately for each antigen isotype;
#' in other words, for the purposes of this argument,
#' row numbers start over at 1 for each antigen isotype. There is currently
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, please line-break after every sentence; it makes code review easier later on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@d-morrison question about this... in this case the sentences were too long to pass through linting (>80 characters), which is why I had to break them at weird points. What do you suggest for the future?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kristinawlai ideally, add line breaks at all sentence ends and also at additional points to make all lines less than 80 characters; good places to break are after commas and before/after grammatical substructures (noun-phrases, verb-phrases, etc). I've recently started experimenting with turning my prose source code into an almost poetry-style format; the compiler will ignore single line breaks anyway and convert it back into a "normal" format, so you can have some fun with the source code formatting.

#' no way to specify different row numbers for different antigen isotypes;
#' if you want to do that, you could call [plot_curve_params_one_ab()]
#' directly for each antigen isotype and combine the resulting panels yourself.
#' Or you could subset `curve_params` manually, before passing it to this
#' function, and set the `n_curves` argument to `Inf`.
#' @return a [ggplot2::ggplot()] object
#' @export
#' @examples
#' \donttest{
#' library(dplyr)
#' library(ggplot2)
#' library(magrittr)
#'
#' curve = load_curve_params("https://osf.io/download/rtw5k/") %>%
#' filter(antigen_iso %in% c("HlyE_IgA", "HlyE_IgG")) %>%
#' slice(1:100, .by = antigen_iso) %>% # Reduce dataset for the purposes of this example
#' slice(1:100, .by = antigen_iso) %>% # Reduce dataset for this example
#' autoplot()
#'
#' curve
#'
autoplot.curve_params = function(
#'}
autoplot.curve_params <- function(
object,
antigen_isos = object$antigen_iso %>% unique(),
antigen_isos = unique(object$antigen_iso),
ncol = min(3, length(antigen_isos)),
...) {
split_data <- object %>%
Expand All @@ -34,8 +44,7 @@
figs <- split_data %>%
lapply(FUN = plot_curve_params_one_ab, ...)

for (i in 1:length(figs))
{
for (i in seq_along(figs)) {

Check warning on line 47 in R/autoplot.curve_params.R

View check run for this annotation

Codecov / codecov/patch

R/autoplot.curve_params.R#L47

Added line #L47 was not covered by tests
figs[[i]] <- figs[[i]] + ggplot2::ggtitle(labels[i])
}

Expand Down
20 changes: 15 additions & 5 deletions man/autoplot.curve_params.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading