Skip to content

Commit

Permalink
updates to version 1.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
hsherrod2019 committed Mar 11, 2024
1 parent d49a03d commit 428a278
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 21 deletions.
4 changes: 2 additions & 2 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 1.0.6
Date: 2023-11-25 12:56:02 UTC
Version: 1.0.7
Date: 2024-03-11 22:12:54 UTC
SHA: 11f89935f939a7a7430eceaba1fda06445134587
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: OpenSpecy
Type: Package
Title: Analyze, Process, Identify, and Share Raman and (FT)IR Spectra
Version: 1.0.6
Date: 2023-11-25
Version: 1.0.7
Date: 2024-03-11
Authors@R: c(person("Win", "Cowger", role = c("cre", "aut", "dtc"),
email = "[email protected]",
comment = c(ORCID = "0000-0001-9226-3104")),
Expand All @@ -13,6 +13,8 @@ Authors@R: c(person("Win", "Cowger", role = c("cre", "aut", "dtc"),
comment = c(ORCID = "0009-0008-3313-4132")),
person("Andrea", "Faltynkova", role = c("aut", "dtc"),
comment = c(ORCID = "0000-0003-2523-3137")),
person("Hannah", "Sherrod", role = c("aut"),
comment = c(ORCID = "0009-0001-0497-8693")),
person("Andrew B", "Gray", role = c("ctb"),
comment = c(ORCID = "0000-0003-2252-7367")),
person("Hannah", "Hapich", role = c("ctb"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ importFrom(signal,sgolay)
importFrom(stats,approx)
importFrom(stats,cor)
importFrom(stats,dist)
importFrom(stats, IQR, quantile)
importFrom(stats,lm)
importFrom(stats,median)
importFrom(stats,model.frame)
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# OpenSpecy 1.0.7

## Minor Improvements

- Modified `manage_na.R`
- Added to NAMESPACE

# OpenSpecy 1.0.6

## Minor Improvements
Expand Down
18 changes: 9 additions & 9 deletions R/manage_na.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
#'
#' @examples
#' manage_na(c(NA, -1, NA, 1, 10))
#' manage_na(c(NA, -1, NA, 1, 10), lead_tail_only = F)
#' manage_na(c(NA, 0, NA, 1, 10), lead_tail_only = F, ig_zero = T)
#' manage_na(c(NA, -1, NA, 1, 10), lead_tail_only = FALSE)
#' manage_na(c(NA, 0, NA, 1, 10), lead_tail_only = FALSE, ig_zero = TRUE)
#' data(raman_hdpe)
#' raman_hdpe$spectra[[1]][1:10] <- NA
#' manage_na(raman_hdpe, fun = make_rel) #would normally return all NA without na.rm = T but doesn't here.
#' manage_na(raman_hdpe, fun = make_rel) #would normally return all NA without na.rm = TRUE but doesn't here.
#' manage_na(raman_hdpe, type = "remove") #will remove the first 10 values we set to NA
#'
#' @author
Expand All @@ -40,26 +40,26 @@ manage_na <- function(x, ...) {

#' @rdname manage_na
#' @export
manage_na.default <- function(x, lead_tail_only = T, ig_zero = F, ...) {
manage_na.default <- function(x, lead_tail_only = TRUE, ig_zero = FALSE, ...) {

if(all(is.na(x))) stop("All intensity values are NA, cannot remove or ignore with manage na.")

if(lead_tail_only){
na_positions <- logical(length(x))
if(is.na(x[1])){
criteria = T
criteria = TRUE
y = 1
while(criteria){
if(is.na(x[y])|(ig_zero & x[y] == 0)) na_positions[y] <- T
if(is.na(x[y])|(ig_zero & x[y] == 0)) na_positions[y] <- TRUE
y = y + 1
criteria = is.na(x[y])|(ig_zero & x[y] == 0)
}
}
if(is.na(x[length(x)])){
criteria = T
criteria = TRUE
y = length(x)
while(criteria){
if(is.na(x[y])|(ig_zero & x[y] == 0)) na_positions[y] <- T
if(is.na(x[y])|(ig_zero & x[y] == 0)) na_positions[y] <- TRUE
y = y - 1
criteria = is.na(x[y])|(ig_zero & x[y] == 0)
}
Expand All @@ -74,7 +74,7 @@ manage_na.default <- function(x, lead_tail_only = T, ig_zero = F, ...) {

#' @rdname manage_na
#' @export
manage_na.OpenSpecy <- function(x, lead_tail_only = T, ig_zero = F, fun, type = "ignore", ...) {
manage_na.OpenSpecy <- function(x, lead_tail_only = TRUE, ig_zero = FALSE, fun, type = "ignore", ...) {

consistent <- x$spectra[, lapply(.SD, manage_na,
lead_tail_only = lead_tail_only,
Expand Down
14 changes: 8 additions & 6 deletions man/manage_na.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/testthat/test-manage_na.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
test_that("manage_na works as expected", {
manage_na(c(NA, -1, NA, 1, 10)) |>
expect_identical(c(TRUE, FALSE, FALSE, FALSE, FALSE))
manage_na(c(NA, -1, NA, 1, 10), lead_tail_only = F) |>
manage_na(c(NA, -1, NA, 1, 10), lead_tail_only = FALSE) |>
expect_identical(c(TRUE, FALSE, TRUE, FALSE, FALSE))
manage_na(c(NA, 0, NA, 1, 10), lead_tail_only = F, ig_zero = T) |>
manage_na(c(NA, 0, NA, 1, 10), lead_tail_only = FALSE, ig_zero = TRUE) |>
expect_identical(c(TRUE, TRUE, TRUE, FALSE, FALSE))

data(raman_hdpe)
Expand Down

0 comments on commit 428a278

Please sign in to comment.