Skip to content

Commit

Permalink
Stats imports (#5514)
Browse files Browse the repository at this point in the history
* add stats:: in front of functions not explicitly imported (#5186)

* add utils:: in front of functions not explicitly imported (#5186)

* explicitly import utils::head and utils::tail (#5186)

---------

Co-authored-by: Kai Lin <[email protected]>
  • Loading branch information
klin333 and klin333 authored Nov 10, 2023
1 parent 567006c commit 4f05313
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -703,3 +703,5 @@ importFrom(lifecycle,deprecated)
importFrom(stats,setNames)
importFrom(tibble,tibble)
importFrom(utils,.DollarNames)
importFrom(utils,head)
importFrom(utils,tail)
4 changes: 2 additions & 2 deletions R/axis-secondary.R
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,

# Map the break values back to their correct position on the primary scale
if (!is.null(range_info$major_source)) {
old_val <- approx(full_range, old_range, range_info$major_source)$y
old_val <- stats::approx(full_range, old_range, range_info$major_source)$y
old_val_trans <- scale$trans$transform(old_val)

# rescale values from 0 to 1
Expand All @@ -252,7 +252,7 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
}

if (!is.null(range_info$minor_source)) {
old_val_minor <- approx(full_range, old_range, range_info$minor_source)$y
old_val_minor <- stats::approx(full_range, old_range, range_info$minor_source)$y
old_val_minor_trans <- scale$trans$transform(old_val_minor)

range_info$minor[] <- round(
Expand Down
8 changes: 4 additions & 4 deletions R/backports.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Backport fix from R 3.3:
# https://github.com/wch/r-source/commit/4efc81c98d262f93de9e7911aaa910f5c63cd00f
if (getRversion() < "3.3") {
absolute.units <- getFromNamespace("absolute.units", "grid")
absolute.units.unit <- getFromNamespace("absolute.units.unit", "grid")
absolute.units.unit.list <- getFromNamespace("absolute.units.unit.list", "grid")
absolute.units.unit.arithmetic <- getFromNamespace("absolute.units.unit.arithmetic", "grid")
absolute.units <- utils::getFromNamespace("absolute.units", "grid")
absolute.units.unit <- utils::getFromNamespace("absolute.units.unit", "grid")
absolute.units.unit.list <- utils::getFromNamespace("absolute.units.unit.list", "grid")
absolute.units.unit.arithmetic <- utils::getFromNamespace("absolute.units.unit.arithmetic", "grid")

backport_unit_methods <- function() {
registerS3method("absolute.units", "unit", absolute.units.unit)
Expand Down
1 change: 1 addition & 0 deletions R/ggplot2-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
#' @importFrom glue glue glue_collapse
#' @importFrom lifecycle deprecated
#' @importFrom stats setNames
#' @importFrom utils head tail
## usethis namespace: end
NULL
2 changes: 1 addition & 1 deletion R/stat-align.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ StatAlign <- ggproto("StatAlign", Stat,
d
})
}
y_val <- approxfun(data$x, data$y)(unique_loc)
y_val <- stats::approxfun(data$x, data$y)(unique_loc)
keep <- !is.na(y_val)
x_val <- unique_loc[keep]
y_val <- y_val[keep]
Expand Down
2 changes: 1 addition & 1 deletion R/stat-ecdf.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ StatEcdf <- ggproto("StatEcdf", Stat,
if (pad) {
x <- c(-Inf, x, Inf)
}
data_ecdf <- ecdf(data$x)(x)
data_ecdf <- stats::ecdf(data$x)(x)

df_ecdf <- data_frame0(
x = x,
Expand Down
2 changes: 1 addition & 1 deletion R/stat-qq-line.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ StatQqLine <- ggproto("StatQqLine", Stat,
}

x_coords <- inject(distribution(p = line.p, !!!dparams))
y_coords <- quantile(sample, line.p)
y_coords <- stats::quantile(sample, line.p)
slope <- diff(y_coords) / diff(x_coords)
intercept <- y_coords[1L] - slope * x_coords[1L]

Expand Down

0 comments on commit 4f05313

Please sign in to comment.