Skip to content

Commit

Permalink
Merge pull request #34 from nutriverse/dev
Browse files Browse the repository at this point in the history
test calculate_relative_tem; fix #28
  • Loading branch information
ernestguevarra authored Dec 18, 2024
2 parents f018889 + 344e7f2 commit c015368
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
14 changes: 10 additions & 4 deletions R/05_calculate_relative_tem.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@
#'
#' x <- smartStdLong[smartStdLong$measure_type == "weight", ]
#'
#' mean_value <- calculate_mean(measures = x$measure_value,
#' index = x[ , "observer"])
#'
#' rel_tem <- calculate_relative_tem(tem = tem, mean_value = mean_value)
#' mean_value <- calculate_mean(
#' measures = x$measure_value, index = x[ , "observer"]
#' )
#'
#' rel_tem <- calculate_relative_tem(
#' tem = tem$tem, mean_value = mean_value$mean
#' )
#'
#' rel_tem
#'
#' @export
#' @rdname calculate_relative_tem
#'

calculate_relative_tem <- function(tem, mean_value) {
Expand All @@ -35,3 +40,4 @@ calculate_relative_tem <- function(tem, mean_value) {
## Return output
relative_tem
}

10 changes: 7 additions & 3 deletions man/calculate_relative_tem.Rd

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

17 changes: 17 additions & 0 deletions tests/testthat/test-05_calculate_relative_tem.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Tests for calculate_relative_tem ---------------------------------------------

tem <- calculate_tem_cohort(
df = smartStd, m1 = "weight1", m2 = "weight2", index = "observer", n = 10
)

x <- smartStdLong[smartStdLong$measure_type == "weight", ]

mean_value <- calculate_mean(
measures = x$measure_value, index = x[ , "observer"]
)

rel_tem <- calculate_relative_tem(tem = tem$tem, mean_value = mean_value$mean)

test_that("calculate_relative_tem works as expected", {
expect_type(rel_tem, "double")
})

0 comments on commit c015368

Please sign in to comment.