Skip to content

Commit

Permalink
chore: use %||% in R/fit.R (#1530)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviator-app[bot] authored Sep 26, 2024
2 parents 6664d62 + 3bf7025 commit b3ad241
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
8 changes: 2 additions & 6 deletions R/epi.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,8 @@ plot.sir <- function(x, comp = c("NI", "NS", "NR"),
quantile_color <- rep(quantile_color, length.out = length(quantiles))

ns <- length(sir)
if (is.null(xlim)) {
xlim <- c(0, max(sapply(sir, function(x) max(x$times))))
}
if (is.null(ylim)) {
ylim <- c(0, max(sapply(sir, function(x) max(x[[comp]]))))
}
xlim <- xlim %||% c(0, max(sapply(sir, function(x) max(x$times))))
ylim <- ylim %||% c(0, max(sapply(sir, function(x) max(x[[comp]]))))

## Generate the plot, first with individual curves, and then
## adding median and quantile curves.
Expand Down
6 changes: 2 additions & 4 deletions R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fit_power_law <- function(
if (implementation == "r.mle") {
power.law.fit.old(x, xmin, start, ...)
} else if (implementation %in% c("plfit", "plfit.p")) {
if (is.null(xmin)) xmin <- -1
xmin <- xmin %||% -1
power.law.fit.new(
x,
xmin = xmin,
Expand All @@ -175,9 +175,7 @@ power.law.fit.old <- function(x, xmin = NULL, start = 2, ...) {
stop("vector should be at least of length two")
}

if (is.null(xmin)) {
xmin <- min(x)
}
xmin <- xmin %||% min(x)

n <- length(x)
x <- x[x >= xmin]
Expand Down

0 comments on commit b3ad241

Please sign in to comment.