test_that("Function get_restricted_mean() calculates restricted mean based on method of choice at time", {
test_result <- get_restricted_mean(rwToT_test_file_A, 365)
#test structure of the output
expect_output(str(test_result), "List of 2")
#test when t is not mature - using pocock method (no parametric output)
expect_equal(test_result$parametric_km, NULL)
# test when t is mature, parametric output
test_result <- get_restricted_mean(rwToT_test_file_B, 730)
test_result <- unlist(regmatches(test_result$mean, gregexpr("[[:alpha:]]+\\.*", test_result$mean)))
expect_equal(test_result, "Weibull")
# test restricted mean output for aml data
test_result <- get_restricted_mean(rwToT_aml, 48)
test_result <- unlist(regmatches(test_result$mean, gregexpr("[[:digit:]]+\\.*[[:digit:]]*", test_result$mean)))
expect_equal(test_result, c("26.7", "21.8", "34.3"))
# warning for n < 10
expect_warning(get_restricted_mean(rwToT_aml[1:2,], 48))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.