Skip to content

Commit

Permalink
Merge pull request #36 from nutriverse/dev
Browse files Browse the repository at this point in the history
test calculate_total_tem; fix #29
  • Loading branch information
ernestguevarra authored Dec 18, 2024
2 parents c015368 + 8a8bdc6 commit bec44db
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/testthat/test-06_calculate_total_tem.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Tests for calculate_total_tem ------------------------------------------------

# Calculate intra-observer TEM
intra <- calculate_tem_cohort(
df = smartStd, m1 = "muac1", m2 = "muac2", index = "observer", n = 11
)

# Get inter-observer TEM
muacDF1 <- subset(
smartStd, select = c(-muac2, -weight1, -weight2, -height1, -height2)
)

muacDF2 <- subset(
smartStd, select = c(-muac1, -weight1, -weight2, -height1, -height2)
)

# Spread the dataset to wide format
muacDF1 <- tidyr::spread(muacDF1, key = "observer", value = "muac1")
muacDF2 <- tidyr::spread(muacDF2, key = "observer", value = "muac2")
muacDF <- merge(muacDF1, muacDF2, by = "subject")
inter <- calculate_team_tem(n = 10, k = 22, m = muacDF[ , 2:23])

total_tem <- calculate_total_tem(intra = intra$tem, inter = inter)

test_that("calculate_total_tem works as expected", {
expect_type(total_tem, "double")
})

0 comments on commit bec44db

Please sign in to comment.