Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions R/01-mapOperations.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#' Get Binary Predictions
#'
#' @param XPred1 (data.frame) prediction matrix of first map
#' @param XPred2 (data.frame) prediction matrix of second map
#' @return (data.frame) prediction matrix of resulting map
getBinaryPredictions <- function(XPred1, XPred2) {
# your code doing the calculations

# this is just a placeholder!
result <- XPred1

# return the result
return(result)
}
19 changes: 19 additions & 0 deletions man/getBinaryPredictions.Rd

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

20 changes: 20 additions & 0 deletions tests/testthat/test-mapOperations.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
testthat::test_that("function getBinaryPredictions", {
# setup test
testPredictions <- readRDS(testthat::test_path("testdata", "test-mapOperations.rds"))
testExpectedColnames <- c("Longitude", "Latitude", "Est", "Sd", "SDPop", "SdTotal", "IntLower",
"IntUpper", "IntLowerTotal", "IntUpperTotal", "resError")

# test the calculation
testXPredResult <- getBinaryPredictions(testPredictions$testXPred1, testPredictions$testXPred2)
expect_true(is.data.frame(testXPredResult))
expect_true(nrow(testXPredResult) > 0)
expect_equal(colnames(testXPredResult), testExpectedColnames)

# test plotting of the map
testInputs <- list(XPred = testXPredResult,
type = "difference",
independent = "")

# we cannot test the output, but we can test if the function runs without error
expect_true(is.list(do.call(plotDS, testInputs)))
})
Binary file added tests/testthat/testdata/test-mapOperations.rds
Binary file not shown.