diff --git a/R/Trend.R b/R/Trend.R index 7096d48db3f7475800a070651f3721659c07ef58..1f6664a07d049ebcfdd6e77605138809db912143 100644 --- a/R/Trend.R +++ b/R/Trend.R @@ -180,7 +180,7 @@ Trend <- function(data, time_dim = 'ftime', interval = 1, polydeg = 1, } else { trend <- rep(NA, polydeg + 1) - detrend <- NA + detrended <- rep(NA, length(x)) if (conf) { conf.lower <- rep(NA, polydeg + 1) @@ -188,7 +188,7 @@ Trend <- function(data, time_dim = 'ftime', interval = 1, polydeg = 1, } if (pval) { - p.val <- NA + p.val <- rep(NA, polydeg + 1) } } diff --git a/tests/testthat/test-Trend.R b/tests/testthat/test-Trend.R index 79049b526b5c0b77c86239b9d64da96503aa2209..49a998229f5ca9336bb5a7c06c1eb8144922411e 100644 --- a/tests/testthat/test-Trend.R +++ b/tests/testthat/test-Trend.R @@ -16,7 +16,10 @@ context("s2dv::Trend tests") set.seed(1) na <- floor(runif(5, min = 1, max = 60)) dat3[na] <- NA - + + # dat4 + dat4 <- dat3 + dat4[, 1, 1, 1] <- NA ############################################## test_that("1. Input checks", { @@ -165,3 +168,16 @@ test_that("4. Output checks: dat3", { }) + +############################################## +test_that("5. Output checks: dat4", { + expect_equal( + Trend(dat4)$detrended[, 1, 1, 1], + as.numeric(rep(NA, 5)) + ) + expect_equal( + Trend(dat4)$p.val[, 1, 1, 1], + c(NA, 0.01800594), + tolerance = 0.0001 + ) +})