Skip to content

Commit

Permalink
Use colMeans() rather than apply(, 2, mean)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisaloo committed Jul 7, 2023
1 parent 90fbb60 commit 1da8445
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/endemic_channel.R
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ endemic_channel <- function(observations, incidence_historic,
FUN = stats::quantile, p = 0.25
))
} else if (method == "mean") {
central <- as.numeric(apply(historic, MARGIN = 2, FUN = mean))
central <- as.numeric(colMeans(historic))
interval <- as.numeric(apply(historic,
MARGIN = 2, FUN = function(x) {
stats::qt(
Expand Down Expand Up @@ -274,7 +274,7 @@ endemic_channel <- function(observations, incidence_historic,
up_lim <- central + abs(interval)
low_lim <- central - abs(interval)
} else if (method == "unusual_behavior") {
central <- as.numeric(apply(historic, MARGIN = 2, FUN = mean))
central <- as.numeric(colMeans(historic))
up_lim <- NULL
low_lim <- NULL
for (c in central) {
Expand Down Expand Up @@ -356,7 +356,7 @@ endemic_outliers <- function(historic, outlier_years, outliers_handling,
handling <- t(replicate(length(outlier_years), handling))
historic[outlier_years, ] <- handling
} else if (outliers_handling == "replaced_by_mean") {
handling <- as.numeric(apply(historic, MARGIN = 2, FUN = mean))
handling <- as.numeric(colMeans(historic))
handling <- t(replicate(length(outlier_years), handling))
historic[outlier_years, ] <- handling
} else if (outliers_handling == "replaced_by_geom_mean") {
Expand Down

0 comments on commit 1da8445

Please sign in to comment.