From 7fede1b08a87230573b06edb072bce85e893dc6a Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 10:51:09 +0200 Subject: [PATCH 01/15] Update .Rbuildignore --- .Rbuildignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.Rbuildignore b/.Rbuildignore index 0bad093..9009af0 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -12,4 +12,5 @@ code_ex.R ^\.Rprofile$c TODO epo.R +NEWS.html From 433346af131c51b6660817b1ab90bac463a0a4a7 Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 10:51:15 +0200 Subject: [PATCH 02/15] Delete NEWS --- NEWS | 145 ----------------------------------------------------------- 1 file changed, 145 deletions(-) delete mode 100644 NEWS diff --git a/NEWS b/NEWS deleted file mode 100644 index 16e3f41..0000000 --- a/NEWS +++ /dev/null @@ -1,145 +0,0 @@ -prospectr 0.2.5 -=============== - -## Improvements and fixes - -* kenStone(): an error in a sanity check that prevented the -function to run when the number of groups to be selected was smaller than the -total number of groups. This sanity check has been fixed. Thanks to -Pogs Manalili for reporting this. - -* kenStone(): this function was failing when when using the Mahalanobis distance -on a matrix of one column. By default the funcion transforms the matrix onto -the Mahalanobis space using either SVD or eigendecomposition. This makes sense -for matrices with more than two columns. However for a matrix of one column, we -now assume that such space is equivalent to the variable divided by the its -standard deviation. Thanks to Sergio Roldán (https://github.com/sdroldan) for -reporting this. - -* spliceCorrection(): correcting more than one point at once (argument splice) -in the spectra was returning an error. This was a bug introduced in -version 0.2.4. Thanks to José Lucas Safanelli (https://github.com/zecojls) -for reporting this. - - -prospectr 0.2.4 -=============== - -## Improvements and fixes - -* baseline(): in some cases the function did not properly capture the baseline -confounding maximum values of a peaks as part of the baseline. This has been -addressed in this version by ensuring the envelope used in the computation of the -convex hull (used to extract the baseline) is properly defined. At the edges, -this envelope has always values higher than any peak of the spectrum. - -* read_nircal(): the function was wrongly identifying actual .nir files as -invalid. This preventing the function from reading any nir file. This has been -fixed. - - -prospectr 0.2.3 -=============== - -## New features - -* The `kenStone` function now includes a new feature that allows to initialize the -calibration sample search with a user-defined subset of observations (which are -to be included in the final calibration subset). Thanks to Thorsten Behrens and -Philipp Baumann for suggesting this feature. - -* The gap-segment derivatives (gapDer) function now allows for high order -derivatives. In previous versions the function only allowed up to derivatives of -4th order, in this version the the function accepts as derivative order -any integer larger than 1. - -## Improvements and fixes -* `binning() `a bug in the creation of the binning groups has been fixed. This bug -is in fact inherited from a problem in the `findInterval()` function. The breaks -(given in the vec arument) might get corrupted when they contain many decimal -places. These breaks (in vec) are used to define the final bins. The problem in -the binning function was that when a frequency -variable (e.g. wavelength) was exactly on the left of the bin -range the variable was assigned to the next bin. In some cases this lead to -small discrepancies in the in the computation of the mean of the bins. - -* `spliceCorrection()` now accepts one or two values as input for the splice -argument. Previously it only accepted a vector of length two. For example, now it -corrrects for splice steps of spectra that originates from spectrometers -with two detectors (i.e. it corrects for the potential abrupt transition -betwteen the two detectors). - -* An extra sanity check has been added to the `read_nircal()` function. The -function evaluaes whether it is indeed a file properly produced by the BUCHI -nircal software. - -* There was a bug in the filter for the 3rd order derivative in gap segment -derivative (`gapDer`) function. One of the factors in the filter had a wrong -negative sign. - -* There was a bug in the `read_nircal` function. It emerged only in some files and -prevented the function from reading the Description field properly - -## Changes -* In the `msc()` function the argument `reference_spc` has been renamed to -`ref_spectrum` to emphasize that its input must be is a vector and not a -matrix of spectra. - -prospectr 0.2.2 -=============== - -## New features - -* a new function for baseline correction was added. See baseline() - -## Improvements and fixes - -* The package was stripping some symbols for Rcpp functions in Makevars in order -to reduce the installation size of the package. Now these lines have been -commented to comply with CRAN policies - -* standardNormalVariate returns now a matrix (previosuly a data.frame) - - -prospectr 0.2.1 -=============== -* New license -* The detrend function now allows to remove trends corresponding to different -polynomial orders. Check the new 'p' argument. -* New preprocessing function: multiplicative scatter correction (msc) -* Now resample() also has a new argument (...) to pass additional arguments to the -splinefun() function (of stats) used within resample() when the argument -interpol = "spline" (the default since version 0.2.0) -* Bug fix: in read_nircal, the description file was not being properly read -* Now performing automatic unit tests with the package testthat - -prospectr 0.2.0 -=============== -* New maintainer [Leo Ramirez-Lopez] -* Updated vignette -* A new function (read_nircal) for reading buchi NIRcal files has been added -* Documentation reviewed -* The description of the continuum removal algorithm is was adjusted. Previously was indicated that the implemented algorithm was based on the search for a local minimum of -the absorbance spectra the algorithm, however in fact it looks for the convex hull. Thanks to Peter Tillmann for noticing this. - -prospectr 0.1.4 -=============== -* Fix bug in kenStone and duplex when the group parameter is used - -prospectr 0.1.3 -=============== -* Fix in DESCRITPION and NAMESPACE as required by Rcpp 0.11 - -prospectr 0.1.2 -=============== -* bug fix for readASD when ASD file version = 7.0 -* add sanity check in spliceCorrection - -prospectr 0.1.1 -=============== -* bug fix for shenkWest when rm.outlier = T -* bug fix for gapDer when input is a data.frame - -prospectr 0.1 -=============== -* Initial release of the package From 130547761b2f98cdf8d3d494c18130810b09e7a1 Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 10:51:19 +0200 Subject: [PATCH 03/15] Create NEWS.md --- NEWS.md | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 NEWS.md diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..16f016f --- /dev/null +++ b/NEWS.md @@ -0,0 +1,150 @@ +# `prospectr` + +`prospectr` 0.2.5 +=============== + +### Improvements and fixes + +* `kenStone()`: an error in a sanity check that prevented the +function to run when the number of groups to be selected was smaller than the +total number of groups. This sanity check has been fixed. Thanks to +Pogs Manalili for reporting this ([#41](https://github.com/l-ramirez-lopez/prospectr/issues/41)). + +* `kenStone()`: this function was failing when when using the Mahalanobis distance +on a matrix of one column. By default the funcion transforms the matrix onto +the Mahalanobis space using either SVD or eigendecomposition. This makes sense +for matrices with more than two columns. However for a matrix of one column, we +now assume that such space is equivalent to the variable divided by the its +standard deviation. Thanks to Sergio Roldan (https://github.com/sdroldan) for +reporting this ([#40](https://github.com/l-ramirez-lopez/prospectr/issues/40])). + + +* `spliceCorrection()`: correcting more than one point at once (argument splice) +in the spectra was returning an error. This was a bug introduced in +version 0.2.4. Thanks to Jose Lucas Safanelli (https://github.com/zecojls) +for reporting this ([#39](https://github.com/l-ramirez-lopez/prospectr/issues/39)). + + +`prospectr` 0.2.4 +=============== + +### Improvements and fixes + +* `baseline()`: in some cases the function did not properly capture the baseline +confounding maximum values of a peaks as part of the baseline. This has been +addressed in this version by ensuring the envelope used in the computation of the +convex hull (used to extract the baseline) is properly defined. At the edges, +this envelope has always values higher than any peak of the spectrum. + +* `read_nircal()`: the function was wrongly identifying actual .nir files as +invalid. This preventing the function from reading any nir file. This has been +fixed. + + +`prospectr` 0.2.3 +=============== + +### New features + +* The `kenStone()` function now includes a new feature that allows to initialize the +calibration sample search with a user-defined subset of observations (which are +to be included in the final calibration subset). Thanks to Thorsten Behrens and +Philipp Baumann for suggesting this feature. + +* The gap-segment derivatives (`gapDer()`) function now allows for high order +derivatives. In previous versions the function only allowed up to derivatives of +4th order, in this version the the function accepts as derivative order +any integer larger than 1. + +### Improvements and fixes +* `binning() `a bug in the creation of the binning groups has been fixed. This bug +is in fact inherited from a problem in the `findInterval()` function. The breaks +(given in the vec arument) might get corrupted when they contain many decimal +places. These breaks (in vec) are used to define the final bins. The problem in +the binning function was that when a frequency +variable (e.g. wavelength) was exactly on the left of the bin +range the variable was assigned to the next bin. In some cases this lead to +small discrepancies in the in the computation of the mean of the bins. + +* ``spliceCorrection()`` now accepts one or two values as input for the splice +argument. Previously it only accepted a vector of length two. For example, now it +corrrects for splice steps of spectra that originates from spectrometers +with two detectors (i.e. it corrects for the potential abrupt transition +betwteen the two detectors). + +* An extra sanity check has been added to the ``read_nircal()`` function. The +function evaluaes whether it is indeed a file properly produced by the BUCHI +nircal software. + +* There was a bug in the filter for the 3rd order derivative in gap segment +derivative (`gapDer()`) function. One of the factors in the filter had a wrong +negative sign. + +* There was a bug in the `read_nircal()` function. It emerged only in some files and +prevented the function from reading the Description field properly + +### Changes +* In the `msc()` function the argument `reference_spc` has been renamed to +`ref_spectrum` to emphasize that its input must be is a vector and not a +matrix of spectra. + +`prospectr` 0.2.2 +=============== + +### New features + +* a new function for baseline correction was added. See `baseline()` + +### Improvements and fixes + +* The package was stripping some symbols for Rcpp functions in Makevars in order +to reduce the installation size of the package. Now these lines have been +commented to comply with CRAN policies + +* `standardNormalVariate()` returns now a matrix (previously a data.frame) + + +`prospectr` 0.2.1 +=============== +* New license +* The detrend function now allows to remove trends corresponding to different +polynomial orders. Check the new 'p' argument. +* New preprocessing function: multiplicative scatter correction (msc) +* Now `resample()` also has a new argument (`...`) to pass additional arguments to the +`splinefun()` function (of stats) used within `resample()` when the argument +`interpol = 'spline'` (the default since version 0.2.0) +* Bug fix: in `read_nircal()`, the description file was not being properly read +* Now performing automatic unit tests with the package testthat + +`prospectr` 0.2.0 +=============== +* New maintainer [Leo Ramirez-Lopez] +* Updated vignette +* A new function (`read_nircal()`) for reading buchi NIRcal files has been added +* Documentation reviewed +* The description of the continuum removal algorithm is was adjusted. Previously +was indicated that the implemented algorithm was based on the search for a +local minimum of the absorbance spectra the algorithm, however in fact it looks +for the convex hull. Thanks to Peter Tillmann for noticing this. + +`prospectr` 0.1.4 +=============== +* Fix bug in `kenStone()` and `duplex()` when the group parameter is used + +`prospectr` 0.1.3 +=============== +* Fix in DESCRITPION and NAMESPACE as required by Rcpp 0.11 + +`prospectr` 0.1.2 +=============== +* bug fix for `readASD()` when ASD file version = 7.0 +* add sanity check in `spliceCorrection()` + +`prospectr` 0.1.1 +=============== +* bug fix for `shenkWest()` when `rm.outlier = TRUE` +* bug fix for `gapDer()` when input is a data.frame + +`prospectr` 0.1 +=============== +* Initial release of the package From 364b8682bbfeda39e335cb6786351b40663434cc Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 11:44:16 +0200 Subject: [PATCH 04/15] Update DESCRIPTION --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index fdd68de..ee5f8e3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -35,7 +35,7 @@ Imports: mathjaxr (>= 1.0), lifecycle (>= 0.2.0) RdMacros: mathjaxr -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.1 NeedsCompilation: yes LazyData: true LazyDataCompression: xz From 552c3b659730ceca1ac635aea53b074d207b552a Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 11:44:51 +0200 Subject: [PATCH 05/15] doc(formula) --- man/cochranTest.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/cochranTest.Rd b/man/cochranTest.Rd index ba572f6..0ef6548 100644 --- a/man/cochranTest.Rd +++ b/man/cochranTest.Rd @@ -49,7 +49,7 @@ An observation is considered to have an outlying variance if the Cochran \emph{C statistic is higher than an upper limit critical value \mjeqn{C_{UL}}{C_{UL}} which can be evaluated with ('t Lam, 2010): -\mjdeqn{C_{UL}(\alpha, n, N) = 1 + [\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}]^{-1} }{C_{UL}(\alpha, n, N) = 1 + [\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}]^{-1}} +\mjdeqn{C_{UL}(\alpha, n, N) = 1 + \[\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}\]^{-1} }{C_{UL}(\alpha, n, N) = 1 + \[\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}\]^{-1}} where \mjeqn{\alpha}{\alpha} is the \emph{p}-value of the test, \mjeqn{n}{n} is the (average) number of replicates and \mjeqn{F_c}{F_c} is the critical value of the Fisher's \mjeqn{F}{F} ratio. From f89b168cc52d7803bf772ea72321ec5e5191cd31 Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 11:44:57 +0200 Subject: [PATCH 06/15] Update NEWS.md --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 16f016f..fd9eccd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,7 +11,7 @@ total number of groups. This sanity check has been fixed. Thanks to Pogs Manalili for reporting this ([#41](https://github.com/l-ramirez-lopez/prospectr/issues/41)). * `kenStone()`: this function was failing when when using the Mahalanobis distance -on a matrix of one column. By default the funcion transforms the matrix onto +on a matrix of one column. By default the function transforms the matrix onto the Mahalanobis space using either SVD or eigendecomposition. This makes sense for matrices with more than two columns. However for a matrix of one column, we now assume that such space is equivalent to the variable divided by the its From d6aadd3ad37009ded166f8377fde507dbdb34a84 Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 11:45:13 +0200 Subject: [PATCH 07/15] style(styler) --- R/baseline.R | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/R/baseline.R b/R/baseline.R index a84d293..7324ae5 100644 --- a/R/baseline.R +++ b/R/baseline.R @@ -50,24 +50,24 @@ baseline <- function(X, wav) { if (is.data.frame(X)) { X <- as.matrix(X) } - + if (missing(wav)) { wav <- 1:ncol(X) } - + wav <- c( wav[1] - diff(wav[1:2]), wav, wav[length(wav)] + diff(wav[(length(wav) - 1):length(wav)]) ) - + # make sure the edges will be well above any peak edges <- abs(apply(X, 1, "max")) + abs(apply(X, 1, "min")) edges <- edges * 2 - + X <- cbind(edges, X, edges) colnames(X) <- wav - + ## simple baseline function simple_bs <- function(x, wav) { id <- sort(chull(wav, x)) @@ -75,7 +75,7 @@ baseline <- function(X, wav) { hull_line <- approx(x = wav[id], y = x[id], xout = wav, method = "linear")$y return(hull_line) } - + if (is.matrix(X)) { if (missing(wav)) { wav <- seq_len(ncol(X)) @@ -87,14 +87,14 @@ baseline <- function(X, wav) { } else { hull_line <- simple_bs(X, wav) } - + hull_line <- hull_line[, -c(1, ncol(hull_line))] X <- X[, -c(1, ncol(X))] - + baselined <- X - hull_line - + wav <- wav[-c(1, length(wav))] - + if (is.matrix(X)) { colnames(hull_line) <- colnames(baselined) <- wav rownames(hull_line) <- rownames(baselined) <- rownames(X) From 968822deb248b3695292815f34e715ea99202244 Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 11:45:17 +0200 Subject: [PATCH 08/15] style(styler) --- R/e2m.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/e2m.R b/R/e2m.R index 7628e78..406e5fc 100644 --- a/R/e2m.R +++ b/R/e2m.R @@ -41,7 +41,7 @@ e2m <- function(X, sm.method = c("svd", "eigen")) { ms_x <- X / sd(X) } else { sm_method <- match.arg(sm.method) - + X <- as.matrix(X) vcv <- cov(X) sq_vcv <- sqrtSm(vcv, method = sm_method) From 9ed1536cd74848b7c4eba9a068e876218aaa25d7 Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 11:45:21 +0200 Subject: [PATCH 09/15] style(styler) --- R/msc.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/msc.R b/R/msc.R index ea9dc04..25f7342 100644 --- a/R/msc.R +++ b/R/msc.R @@ -15,9 +15,9 @@ #' @param ref_spectrum a numeric vector corresponding to an "ideal" reference #' spectrum (e.g. free of scattering effects). By default the function uses the #' mean spectrum of the input \code{X}. See details. Note that this argument was -#' previously named as `reference_spc`, however, it has been renamed to -#' `ref_spectrum` to emphasize that this argument is a vector and not a -#' matrix of spectra. +#' previously named as `reference_spc`, however, it has been renamed to +#' `ref_spectrum` to emphasize that this argument is a vector and not a +#' matrix of spectra. #' #' @details #' The Multiplicative Scatter Correction (MSC) is a normalization method that @@ -47,7 +47,7 @@ #' @examples #' data(NIRsoil) #' NIRsoil$msc_spc <- msc(X = NIRsoil$spc) -#' +#' #' # 10 first msc spectra #' matplot( #' x = as.numeric(colnames(NIRsoil$msc_spc)), From 1145bdf42c67f3c004a66b0b64031fc5111f5647 Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 11:45:25 +0200 Subject: [PATCH 10/15] style(styler) --- R/spliceCorrection.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/spliceCorrection.R b/R/spliceCorrection.R index c019ba6..7284a54 100644 --- a/R/spliceCorrection.R +++ b/R/spliceCorrection.R @@ -2,11 +2,11 @@ #' @description #' Corrects steps in an input spectral matrix by linear interpolation of the #' values of the edges of the middle sensor -#' +#' #' @usage -#' +#' #' spliceCorrection(X, wav, splice = c(1000, 1830), interpol.bands = 10) -#' +#' #' @param X a numeric matrix or vector to transform (optionally a data frame that can #' be coerced to a numerical matrix). #' @param wav a numeric vector with band positions. From 6d988c2ad30494a2475707191996255547cb1816 Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 11:45:29 +0200 Subject: [PATCH 11/15] style(styler) --- tests/testthat/test-kenStone.R | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/tests/testthat/test-kenStone.R b/tests/testthat/test-kenStone.R index efb5a22..8b5988e 100644 --- a/tests/testthat/test-kenStone.R +++ b/tests/testthat/test-kenStone.R @@ -8,21 +8,23 @@ test_that("kenStone works", { expect_is(X_kenStone, "list") - sel_samples <- c(687, 377, 410, 619, 87, 618, 611, 283, 317, 666, 789, 635, - 147, 822, 285, 313, 737, 803, 819, 383, 823, 204, 591, 252, - 825, 272, 402, 39, 330, 590, 286, 608, 363, 234, 701, 718, - 287, 270, 571, 192, 614, 1, 386, 615, 126, 755, 734, 428, - 466, 426) + sel_samples <- c( + 687, 377, 410, 619, 87, 618, 611, 283, 317, 666, 789, 635, + 147, 822, 285, 313, 737, 803, 819, 383, 823, 204, 591, 252, + 825, 272, 402, 39, 330, 590, 286, 608, 363, 234, 701, 718, + 287, 270, 571, 192, 614, 1, 386, 615, 126, 755, 734, 428, + 466, 426 + ) expect_true(!any(!sel_samples == X_kenStone$model)) - + X_kenStone_b <- kenStone( NIRsoil$spc, k = 50, metric = "mahal", - pc = 3, + pc = 3, init = X_kenStone$model[1:10] ) - + expect_true(!any(!sel_samples == X_kenStone_b$model)) }) @@ -40,11 +42,12 @@ test_that("kenStone works with groups", { if (length(my_groups) != nrow(x)) { my_groups <- c(rep(nrow(x), nrow(x) - length(my_groups)), my_groups) } - - X_kenStone <- kenStone(x, - k = 30, - pc = 2, - group = as.factor(my_groups)) - + + X_kenStone <- kenStone(x, + k = 30, + pc = 2, + group = as.factor(my_groups) + ) + expect_true(all(diff(X_kenStone$model[1:n_per_group]) == 1)) -}) \ No newline at end of file +}) From 02ab4d464634cad9cee37489017c8f5c65840b43 Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 11:45:33 +0200 Subject: [PATCH 12/15] style(styler) --- tests/testthat/test-msc.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-msc.R b/tests/testthat/test-msc.R index 9a396c3..c77112b 100644 --- a/tests/testthat/test-msc.R +++ b/tests/testthat/test-msc.R @@ -8,7 +8,7 @@ test_that("msc", { expect_is(X_msc, "matrix") expect_true(round(max(X_msc[1, ]), 5) == 0.37394) expect_true(round(min(X_msc[1, ]), 5) == 0.29474) - + X_mscb <- msc(NIRsoil$spc, apply(NIRsoil$spc, 2, median)) expect_true(round(max(X_mscb[1, ]), 5) == 0.34816) expect_true(round(min(X_mscb[1, ]), 5) == 0.26749) From dafe0f16b35024f4d1be833fcab5c897f32b29e4 Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 12:01:48 +0200 Subject: [PATCH 13/15] test(expect true) --- tests/testthat/test-kenStone.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-kenStone.R b/tests/testthat/test-kenStone.R index 8b5988e..b090fa5 100644 --- a/tests/testthat/test-kenStone.R +++ b/tests/testthat/test-kenStone.R @@ -30,7 +30,8 @@ test_that("kenStone works", { test_that("kenStone with Mahalanobis on 1 single variable", { data("NIRsoil") - X_kenStone <- kenStone(NIRsoil$spc, k = 3, metric = "mahal", pc = 1) + expect_true(is.list(kenStone(NIRsoil$spc, k = 3, metric = "mahal", pc = 1))) + }) From 0f7006f827debd94fa6851e06fce7345fc3dd39c Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 13:14:21 +0200 Subject: [PATCH 14/15] doc(correct syntax for formula) --- R/cochranTest.R | 2 +- man/cochranTest.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/cochranTest.R b/R/cochranTest.R index f045521..3c21de6 100644 --- a/R/cochranTest.R +++ b/R/cochranTest.R @@ -39,7 +39,7 @@ #' which can be evaluated with ('t Lam, 2010): #' #' -#' \mjdeqn{C_{UL}(\alpha, n, N) = 1 + \[\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}\]^{-1} }{C_{UL}(\alpha, n, N) = 1 + \[\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}\]^{-1}} +#' \mjdeqn{C_{UL}(\alpha, n, N) = 1 + [\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}]^{-1} }{C_{UL}(\alpha, n, N) = 1 + [\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}]^{-1}} #' #' where \mjeqn{\alpha}{\alpha} is the *p*-value of the test, \mjeqn{n}{n} is the (average) #' number of replicates and \mjeqn{F_c}{F_c} is the critical value of the Fisher's \mjeqn{F}{F} ratio. diff --git a/man/cochranTest.Rd b/man/cochranTest.Rd index 0ef6548..ba572f6 100644 --- a/man/cochranTest.Rd +++ b/man/cochranTest.Rd @@ -49,7 +49,7 @@ An observation is considered to have an outlying variance if the Cochran \emph{C statistic is higher than an upper limit critical value \mjeqn{C_{UL}}{C_{UL}} which can be evaluated with ('t Lam, 2010): -\mjdeqn{C_{UL}(\alpha, n, N) = 1 + \[\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}\]^{-1} }{C_{UL}(\alpha, n, N) = 1 + \[\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}\]^{-1}} +\mjdeqn{C_{UL}(\alpha, n, N) = 1 + [\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}]^{-1} }{C_{UL}(\alpha, n, N) = 1 + [\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}]^{-1}} where \mjeqn{\alpha}{\alpha} is the \emph{p}-value of the test, \mjeqn{n}{n} is the (average) number of replicates and \mjeqn{F_c}{F_c} is the critical value of the Fisher's \mjeqn{F}{F} ratio. From fdb79aff45e98ac5ed7e628de73d227c83433f19 Mon Sep 17 00:00:00 2001 From: Leonardo Ramirez-Lopez Date: Tue, 19 Jul 2022 14:07:48 +0200 Subject: [PATCH 15/15] Update my-comments.md --- my-comments.md | 112 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 105 insertions(+), 7 deletions(-) diff --git a/my-comments.md b/my-comments.md index 4f88586..84620a7 100644 --- a/my-comments.md +++ b/my-comments.md @@ -4,12 +4,20 @@ # submission message: Dear CRAN maintainers, -I am submitting my package "prospectr" to CRAN. This version accounts a bug in one function. -Prior to this submission, this tarball has been checked in rhub under the main platforms. +I am submitting my package "prospectr" to CRAN. This version accounts for some bugs. +Prior to this submission, this tarball has been checked with in the winbuilder service. Apart from that it has been also submitted to extensive tests in rhub. +A first submission of this version failed (for "r-devel-linux-x86_64-debian-gcc"), +therefore following platforms were tested for a second submission using Rhub: +- Debian Linux, R-devel, GCC ASAN/UBSAN +- Debian Linux, R-devel, GCC, no long double +- Debian Linux, R-devel, clang, ISO-8859-15 locale +- Debian Linux, R-devel, GCC +For this second submission the package passed all the tests in the above platforms. Reverse dependencies have also been checked. Best regards, Leonardo + ## Package was built using: ``` devtools::build( @@ -23,9 +31,8 @@ devtools::build( ) ``` -# The release of `prospectr 0.2.5` (`antilla`) was uploaded on the R win builder -service on 18.07.2022 at around 21:00, however at 10:00 am on 18.07.2022 the -checks had not been processed. Therefore winbuilder was not used for this release. +# R win builder checks for release of `prospectr 0.2.5` (`antilla`) 19.07.2022 +passed all the checks without notes. # Rhub checks for release of `prospectr 0.2.5` (`antilla`) 18.07.2022 The checks were conducted in the following platforms through rhub: @@ -35,6 +42,8 @@ rhub::check(paste0(gsub("/prospectr$", "/", getwd()), "prospectr_0.2.5.tar.gz"), platform = c("fedora-gcc-devel"), email = "ramirez.lopez.leo@gmail.com") ``` +- "linux-x86_64-rocker-gcc-san" + - "fedora-gcc-devel" NOTE installed size is 6.6Mb sub-directories of 1Mb or more: @@ -90,6 +99,8 @@ devtools::build( ) ``` + + # R win builder checks for release of `prospectr 0.2.4` (`mandarina`) 03.04.2022 passed all the checks without notes # Rhub checks for release of `prospectr 0.2.4` (`mandarina`) 03.04.2022 @@ -100,12 +111,24 @@ rhub::check(paste0(gsub("/prospectr$", "/", getwd()), "prospectr_0.2.4.tar.gz"), platform = c("fedora-gcc-devel"), email = "ramirez.lopez.leo@gmail.com") ``` +Since there was an error with the first submission (with the flavor +"r-devel-linux-x86_64-debian-gcc"), the following platforms were added: +linux-x86_64-rocker-gcc-san; debian-gcc-devel-nold; debian-gcc-devel + + +- linux-x86_64-rocker-gcc-san OK + +- debian-gcc-devel-nold OK + +- debian-gcc-devel OK + + - "fedora-gcc-devel" * checking installed package size ... NOTE - installed size is 6.8Mb + installed size is 6.6Mb sub-directories of 1Mb or more: data 1.9Mb - libs 4.0Mb + libs 3.9Mb - "windows-x86_64-devel" OK @@ -127,6 +150,81 @@ rhub::check(paste0(gsub("/prospectr$", "/", getwd()), "prospectr_0.2.4.tar.gz"), - "solaris-x86-patched-ods" OK +# A first submission to CRAN was rejected. The problem: + +Flavor: r-devel-linux-x86_64-debian-gcc +Check: package subdirectories, Result: NOTE + Problems with news in 'NEWS': + Cannot process chunk/lines: + function to run when the number of groups to be selected was smaller than the + Cannot process chunk/lines: + total number of groups. This sanity check has been fixed. Thanks to + Cannot process chunk/lines: + on a matrix of one column. By default the funcion transforms the matrix onto + Cannot process chunk/lines: + the Mahalanobis space using either SVD or eigendecomposition. This makes sense + Cannot process chunk/lines: + for matrices with more than two columns. However for a matrix of one column, we + Cannot process chunk/lines: + now assume that such space is equivalent to the variable divided by the its + Cannot process chunk/lines: + standard deviation. Thanks to Sergio Roldán (https://github.com/sdroldan) for + Cannot process chunk/lines: + in the spectra was returning an error. This was a bug introduced in + Cannot process chunk/lines: + for reporting this. + Cannot process chunk/lines: + confounding maximum values of a peaks as part of the baseline. This has been + Cannot process chunk/lines: + addressed in this version by ensuring the envelope used in the computation of the + Cannot process chunk/lines: + convex hull (used to extract the baseline) is properly defined. At the edges, + Cannot process chunk/lines: + invalid. This preventing the function from reading any nir file. This has been + Cannot process chunk/lines: + fixed. + Cannot process chunk/lines: + calibration sample search with a user-defined subset of observations (which are + Cannot process chunk/lines: + to be included in the final calibration subset). Thanks to Thorsten Behrens and + Cannot process chunk/lines: + derivatives. In previous versions the function only allowed up to derivatives of + 4th order, in this version the the function accepts as derivative order + Cannot process chunk/lines: + any integer larger than 1. + ## Improvements and fixes + * `binning() `a bug in the creation of the binning groups has been fixed. This bug + Cannot process chunk/lines: + is in fact inherited from a problem in the `findInterval()` function. The breaks + (given in the vec arument) might get corrupted when they contain many decimal + Cannot process chunk/lines: + places. These breaks (in vec) are used to define the final bins. The problem in + Cannot process chunk/lines: + the binning function was that when a frequency + Cannot process chunk/lines: + variable (e.g. wavelength) was exactly on the left of the bin + Cannot process chunk/lines: + range the variable was assigned to the next bin. In some cases this lead to + Cannot process chunk/lines: + argument. Previously it only accepted a vector of length two. For example, now it + Cannot process chunk/lines: + corrrects for splice steps of spectra that originates from spectrometers + Cannot process chunk/lines: + with two detectors (i.e. it corrects for the potential abrupt transition + Cannot process chunk/lines: + function evaluaes whether it is indeed a file properly produced by the BUCHI + Cannot process chunk/lines: + derivative (`gapDer`) function. One of the factors in the filter had a wrong + Cannot process chunk/lines: + prevented the function from reading the Description field properly + ## Changes + * In the `msc()` function the argument `reference_spc` has been renamed to + `ref_spectrum` to emphasize that its input must be is a vector and not a + Cannot process chunk/lines: + matrix of spectra. + Cannot process chunk/lines: + to reduce the installation size of the package. Now these lines have been + # version 0.2.3