jranke / pfm
Showing 1 of 51 files from the diff.
Other files ignored by Codecov
man/endpoint.Rd has changed.
docs/index.html has changed.
man/PEC_sw_sed.Rd has changed.
man/set_nd_nq.Rd has changed.
man/PEC_soil.Rd has changed.
man/TOXSWA_cwa.Rd has changed.
man/one_box.Rd has changed.
man/GUS.Rd has changed.
man/sawtooth.Rd has changed.
DESCRIPTION has changed.
ChangeLog has changed.
man/geomean.Rd has changed.

@@ -1,4 +1,4 @@
Loading
1 -
# Copyright (C) 2015  Johannes Ranke
1 +
# Copyright (C) 2015,2020  Johannes Ranke
2 2
# Contact: jranke@uni-bremen.de
3 3
# This file is part of the R package pfm
4 4
@@ -19,8 +19,9 @@
Loading
19 19
#'
20 20
#' Based on some posts in a thread on Stackoverflow
21 21
#' \url{http://stackoverflow.com/questions/2602583/geometric-mean-is-there-a-built-in}
22 -
#' This function checks for negative values, removes NA values per default and
23 -
#' returns 0 if at least one element of the vector is 0.
22 +
#' This function returns NA if NA values are present and na.rm = FALSE
23 +
#' (default). If negative values are present, it gives an error message.
24 +
#' If at least one element of the vector is 0, it returns 0.
24 25
#'
25 26
#' @param x Vector of numbers
26 27
#' @param na.rm Should NA values be omitted?
@@ -31,8 +32,8 @@
Loading
31 32
#' geomean(c(1, 3, 9))
32 33
#' geomean(c(1, 3, NA, 9))
33 34
#' \dontrun{geomean(c(1, -3, 9)) # returns an error}
34 -
geomean = function(x, na.rm = TRUE){
35 -
  if (any(is.na(x)) & na.rm == FALSE) stop("Removal of NA values was not requested")
35 +
geomean = function(x, na.rm = FALSE) {
36 +
  if (any(is.na(x)) & na.rm == FALSE) return(NA)
36 37
  if (any(x < 0, na.rm = na.rm)) stop("Only defined for positive numbers")
37 38
  exp(mean(log(x), na.rm = na.rm))
38 39
}
Files Coverage
R 69.12%
Project Totals (16 files) 69.12%
Notifications are pending CI completion. Waiting for GitHub's status webhook to queue notifications. Push notifications now.
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading