Skip to content

Commit 17aa382

Browse files
committed
accommodate missing species. Closes #46.
1 parent b83bf22 commit 17aa382

File tree

6 files changed

+45
-2
lines changed

6 files changed

+45
-2
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: otndo
22
Title: Understand your OTN data
3-
Version: 0.3.3
3+
Version: 0.3.4
44
Authors@R:
55
person("Michael", "O'Brien", , "mike@obrien.page", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0003-1420-6395"))

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## otndo 0.3
2+
### v 0.3.4
3+
* Fix bug introduced in v 0.3.0 where receiver match tables couldn't be created if the source network does not share species data. [Issue #46](https://github.com/mhpob/otndo/issues/46)
4+
25
### v 0.3.3
36
* Fix bug where reports would be silently dropped if it matched a file name that already existed. [Issue #45](https://github.com/mhpob/otndo/issues/45)
47

R/match_table.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ match_table <- function(
8585
),
8686
PI_emails = reactable::colDef(show = F),
8787
POC_emails = reactable::colDef(show = F),
88-
`Project name` = reactable::colDef(minWidth = 200)
88+
`Project name` = reactable::colDef(minWidth = 200),
89+
Species = reactable::colDef(show = !all(is.na(mt_data$Species)))
8990
)
9091
)
9192
}
@@ -104,6 +105,10 @@ prep_match_table <- function(
104105

105106
extract <- data.table::data.table(extract)
106107

108+
if (isFALSE("scientificname" %in% names(extract))) {
109+
extract[, scientificname := character()]
110+
}
111+
107112
if (type == "tag") {
108113
mt <- merge(
109114
extract[, .(detections = .N), by = c("detectedby", "scientificname")],

otndo.Rproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Version: 1.0
2+
ProjectId: 17390ab4-b811-421c-b728-dee2ac2db051
23

34
RestoreWorkspace: No
45
SaveWorkspace: No

tests/testthat/test-match_table.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,17 @@ test_that("creates a js table for tag data", {
4141
)
4242
)
4343
})
44+
45+
46+
47+
test_that("species columnn is dropped if no species present", {
48+
qual <- read.csv(pbsm$qualified)
49+
qual$scientificname <- NULL
50+
51+
tbl_qual <- match_table(qual, "receiver")
52+
53+
expect_false(tbl_qual$x$tag$attribs$columns[[6]]$show)
54+
55+
expect_s3_class(tbl_qual, c("reactable", "htmlwidget"), exact = TRUE)
56+
expect_type(tbl_qual$x, "list")
57+
})

tests/testthat/test-prep_match_table.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,23 @@ test_that("receiver project with multiple species is summarized", {
1818
c(2, 1)
1919
)
2020
})
21+
22+
23+
test_that("networks without species info (ACT) work", {
24+
qual <- read.csv(pbsm$qualified)
25+
qual$scientificname <- NULL
26+
27+
tbl_no_spp <- prep_match_table(qual, "receiver")
28+
29+
# Make sure the test was set up correctly
30+
# No spp info means each project should be represented once.
31+
expect_equal(
32+
nrow(tbl_no_spp),
33+
data.table::uniqueN(tbl_no_spp, by = "Project name")
34+
)
35+
36+
expect_true(
37+
all(is.na(tbl_no_spp$Species))
38+
)
39+
40+
})

0 commit comments

Comments
 (0)