library(moin)
context("moin_cult_network")
test_that("correct class", {
set.seed(1234)
result <- moin_cult_network(nodes_x=sample(3433806:3581396, 10, replace = TRUE),
nodes_y=sample(5286004:5484972, 10, replace = TRUE),
nodes_id=c(1:10),
features=data.frame(x=sample(3433806:3581396, 100, replace = TRUE),
y=sample(5286004:5484972, 100, replace = TRUE),
type=paste0("B", c(rep(1, 5), rep(2,15), sample(11:19, 20, replace = TRUE),
sample(111:119, 30, replace = TRUE), sample(1111:1115, 30, replace = TRUE)))
),
type_col="type" , pre_size=1, method = "euclidean", plotted = TRUE,network_method ="mdm", par = 50000, mode = "undirected", crs = NA)
expect_equal(class(result), class(list()))
})
test_that("correct result", {
set.seed(1234)
result <- moin_cult_network(nodes_x=sample(3433806:3581396, 10, replace = TRUE),
nodes_y=sample(5286004:5484972, 10, replace = TRUE),
nodes_id=c(1:10),
features=data.frame(x=sample(3433806:3581396, 100, replace = TRUE),
y=sample(5286004:5484972, 100, replace = TRUE),
type=paste0("B", c(rep(1, 5), rep(2,15), sample(11:19, 20, replace = TRUE),
sample(111:119, 30, replace = TRUE), sample(1111:1115, 30, replace = TRUE)))
),
type_col="type" , pre_size=1, method = "euclidean", plotted = TRUE,network_method ="mdm", par = 50000, mode = "undirected", crs = NA)
expected_matrix <- matrix(c(0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
4.123106, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 4.123106, 0.000000, 0.000000),ncol=5,dimnames=list(c("1","2","3","4","5"),c("1","2","3","4","5")))
expect_equal(round(result$trunc_cult_dist_matr[1:5,1:5],3),
round(expected_matrix,3))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.