From b7ef48caf5bd0bbaa4ff77ef887f8ff71b5e3d1f Mon Sep 17 00:00:00 2001 From: aho Date: Wed, 29 Jan 2020 12:56:57 +0100 Subject: [PATCH] Remove 'stats' dim in output --- R/Eno.R | 15 ++++++++------- man/Eno.Rd | 10 +++++----- tests/testthat/test-Eno.R | 7 ++----- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/R/Eno.R b/R/Eno.R index aac2197c..6c787743 100644 --- a/R/Eno.R +++ b/R/Eno.R @@ -1,8 +1,8 @@ #'Compute effective sample size with classical method #' #'Compute the number of effective samples along one dimension of an array. This -#'effective number of independent observations can be used in statistical/inference -#'tests.\cr +#'effective number of independent observations can be used in +#'statistical/inference tests.\cr #'The calculation is based on eno function from Caio Coelho from rclim.txt. #' #'@param data A numeric array with named dimensions. @@ -14,9 +14,9 @@ #'@param ncores An integer indicating the number of cores to use for parallel #' computation. The default value is NULL. #' -#'@return An array with the first dimension 'stats', which is the number of -#' effective samples, and the following dimensions are same as parameter 'data' -#' except the time_dim dimension, which is removed after the computation. +#'@return An array with the same dimension as parameter 'data' except the +#' time_dim dimension, which is removed after the computation. The array +#' indicates the number of effective sample along time_dim. #' #'@keywords datagen #'@author History:\cr @@ -82,7 +82,7 @@ Eno <- function(data, time_dim = 'sdate', na.action = na.pass, ncores = NULL) { eno <- Apply(data = list(data), target_dims = time_dim, - output_dims = 'stats', + output_dims = NULL, fun = .Eno, na.action = na.action, ncores = ncores)$output1 @@ -103,5 +103,6 @@ Eno <- function(data, time_dim = 'sdate', na.action = na.pass, ncores = NULL) { } else { eno <- NA } - return(as.array(eno)) + + return(eno) } diff --git a/man/Eno.Rd b/man/Eno.Rd index 02506785..53f28131 100644 --- a/man/Eno.Rd +++ b/man/Eno.Rd @@ -20,14 +20,14 @@ The default value is na.pass.} computation. The default value is NULL.} } \value{ -An array with the first dimension 'stats', which is the number of - effective samples, and the following dimensions are same as parameter 'data' - except the time_dim dimension, which is removed after the computation. +An array with the same dimension as parameter 'data' except the + time_dim dimension, which is removed after the computation. The array + indicates the number of effective sample along time_dim. } \description{ Compute the number of effective samples along one dimension of an array. This -effective number of independent observations can be used in statistical/inference -tests.\cr +effective number of independent observations can be used in +statistical/inference tests.\cr The calculation is based on eno function from Caio Coelho from rclim.txt. } \examples{ diff --git a/tests/testthat/test-Eno.R b/tests/testthat/test-Eno.R index 5c11dee9..1b85092c 100644 --- a/tests/testthat/test-Eno.R +++ b/tests/testthat/test-Eno.R @@ -58,19 +58,16 @@ test_that("2. Output checks: dat1", { expect_equal( dim(res), - dim(array(dim = c(stats = 1, dataset = 1, member = 2, ftime = 4, lat = 10, lon = 10))) + dim(array(dim = c(dataset = 1, member = 2, ftime = 4, lat = 10, lon = 10))) ) - expect_equal( length(res[which(is.na(res))]), 1 ) - expect_equal( length(res[which(res != 4)]), 37 ) - expect_equal( mean(res, na.rm = T), 2.768103, @@ -85,7 +82,7 @@ test_that("3. Output checks: dat2", { expect_equal( Eno(dat2, time_dim = 'date'), - array(c(6.237689, 5.683186), dim = c(stats = 1, ftime = 2)), + array(c(6.237689, 5.683186), dim = c(ftime = 2)), tolerance = 0.0001 ) -- GitLab