Running ‘testthat.R’ [1s/2s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(segregation)
  > 
  > test_check("segregation")
  ── 1. Error: mutual_difference (@test_mutual_diff_mrc.R#16)  ───────────────────
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: mutual_difference(test_data1, test_data2, "u", "g", weight = "n", method = "mrc") at testthat/test_mutual_diff_mrc.R:16
  2: method(d1, d2, unit, group)
  3: d1[, list(p_unit = sum(freq)/n_total1), by = unit]
  4: `[.data.table`(d1, , list(p_unit = sum(freq)/n_total1), by = unit)
  
  .── 2. Error: mutual_difference SE (@test_mutual_diff_mrc.R#33)  ────────────────
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: mutual_difference(test_data1, test_data2, "u", "g", weight = "n", method = "mrc", 
         se = TRUE) at testthat/test_mutual_diff_mrc.R:33
  2: lapply(1:n_bootstrap, function(i) {
         cat(".")
         resampled1 <- d1[sample(.N, n_total1, replace = TRUE, prob = freq)][, list(freq = .N), 
             by = vars]
         resampled2 <- d2[sample(.N, n_total2, replace = TRUE, prob = freq)][, list(freq = .N), 
             by = vars]
         method(resampled1, resampled2, unit, group)
     })
  3: FUN(X[[i]], ...)
  4: method(resampled1, resampled2, unit, group)
  5: d1[, list(p_unit = sum(freq)/n_total1), by = unit]
  6: `[.data.table`(d1, , list(p_unit = sum(freq)/n_total1), by = unit)
  
  ── 3. Error: mutual_mrc same as mutual_total (@test_mutual_diff_mrc.R#40)  ─────
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: expect_equal(mutual_difference(test_data1, test_data2, "u", "g", weight = "n", method = "mrc")[["M1", 
         "est"]], mutual_total(test_data1, "u", "g", weight = "n")[["M", "est"]]) at testthat/test_mutual_diff_mrc.R:40
  2: quasi_label(enquo(object), label)
  3: eval_bare(get_expr(quo), get_env(quo))
  4: mutual_difference(test_data1, test_data2, "u", "g", weight = "n", method = "mrc")
  5: method(d1, d2, unit, group)
  6: d1[, list(p_unit = sum(freq)/n_total1), by = unit]
  7: `[.data.table`(d1, , list(p_unit = sum(freq)/n_total1), by = unit)
  
  ── 4. Error: mutual_mrc same as mutual_total (zero weights) (@test_mutual_diff_m
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: expect_equal(mutual_difference(test_data1, test_data2, "u", "g", weight = "n", method = "mrc")[["M1", 
         "est"]], mutual_total(test_data1, "u", "g", weight = "n")[["M", "est"]]) at testthat/test_mutual_diff_mrc.R:62
  2: quasi_label(enquo(object), label)
  3: eval_bare(get_expr(quo), get_env(quo))
  4: mutual_difference(test_data1, test_data2, "u", "g", weight = "n", method = "mrc")
  5: method(d1, d2, unit, group)
  6: d1[, list(p_unit = sum(freq)/n_total1), by = unit]
  7: `[.data.table`(d1, , list(p_unit = sum(freq)/n_total1), by = unit)
  
  ── 5. Error: mutual_mrc same both ways (@test_mutual_diff_mrc.R#73)  ───────────
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: expect_equal(mutual_difference(test_data1, test_data2, "u", "g", weight = "n", method = "mrc")[["diff", 
         "est"]], mutual_difference(test_data1, test_data2, "g", "u", weight = "n", method = "mrc")[["diff", 
         "est"]]) at testthat/test_mutual_diff_mrc.R:73
  2: quasi_label(enquo(object), label)
  3: eval_bare(get_expr(quo), get_env(quo))
  4: mutual_difference(test_data1, test_data2, "u", "g", weight = "n", method = "mrc")
  5: method(d1, d2, unit, group)
  6: d1[, list(p_unit = sum(freq)/n_total1), by = unit]
  7: `[.data.table`(d1, , list(p_unit = sum(freq)/n_total1), by = unit)
  
  ── 6. Error: mutual_mrc empty cells (@test_mutual_diff_mrc.R#88)  ──────────────
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: mutual_difference(test_data1, test_data2, "u", "g", weight = "n", method = "mrc") at testthat/test_mutual_diff_mrc.R:88
  2: method(d1, d2, unit, group)
  3: d1[, list(p_unit = sum(freq)/n_total1), by = unit]
  4: `[.data.table`(d1, , list(p_unit = sum(freq)/n_total1), by = unit)
  
  ── 7. Error: (unknown) (@test_mutual_local.R#10)  ──────────────────────────────
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: mutual_local(test_data, "u", "g", weight = "n") at testthat/test_mutual_local.R:10
  2: mutual_local_compute(d, unit, group)
  3: data[, `:=`(n_unit, sum(freq)), by = unit]
  4: `[.data.table`(data, , `:=`(n_unit, sum(freq)), by = unit)
  
  ── 8. Error: mutual works both ways around (@test_mutual_total.R#12)  ──────────
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: expect_equal(mutual_total(test_data, "u", "g", weight = "n")[["M", "est"]], mutual_total(test_data, 
         "g", "u", weight = "n")[["M", "est"]]) at testthat/test_mutual_total.R:12
  2: quasi_label(enquo(object), label)
  3: eval_bare(get_expr(quo), get_env(quo))
  4: mutual_total(test_data, "u", "g", weight = "n")
  5: mutual_total_compute(d, unit, group, within)
  6: n_within[, `:=`(n_within = sum(n_within_unit)), by = within]
  7: `[.data.table`(n_within, , `:=`(n_within = sum(n_within_unit)), by = within)
  
  ── 9. Error: between + within = total (@test_mutual_total.R#29)  ───────────────
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: expect_equal(mutual_total(test_data, "u", "g", weight = "n")[["M", "est"]], mutual_total(test_data, 
         "u", "supergroup", weight = "n")[["M", "est"]] + mutual_total(test_data, "u", 
         "g", within = "supergroup", weight = "n")[["M", "est"]]) at testthat/test_mutual_total.R:29
  2: quasi_label(enquo(object), label)
  3: eval_bare(get_expr(quo), get_env(quo))
  4: mutual_total(test_data, "u", "g", weight = "n")
  5: mutual_total_compute(d, unit, group, within)
  6: n_within[, `:=`(n_within = sum(n_within_unit)), by = within]
  7: `[.data.table`(n_within, , `:=`(n_within = sum(n_within_unit)), by = within)
  
  ── 10. Error: within estimations is correct (@test_mutual_total.R#39)  ─────────
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: expect_equal(p_12 * mutual_total(test_data[test_data$supergroup == 12, ], "u", "g", 
         weight = "n")[["M", "est"]] + p_34 * mutual_total(test_data[test_data$supergroup == 
         34, ], "u", "g", weight = "n")[["M", "est"]], mutual_total(test_data, "u", "g", 
         within = "supergroup", weight = "n")[["M", "est"]]) at testthat/test_mutual_total.R:39
  2: quasi_label(enquo(object), label)
  3: eval_bare(get_expr(quo), get_env(quo))
  4: mutual_total(test_data[test_data$supergroup == 12, ], "u", "g", weight = "n")
  5: mutual_total_compute(d, unit, group, within)
  6: n_within[, `:=`(n_within = sum(n_within_unit)), by = within]
  7: `[.data.table`(n_within, , `:=`(n_within = sum(n_within_unit)), by = within)
  
  .── 11. Error: bootstrapping works (@test_mutual_total.R#47)  ───────────────────
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: mutual_total(test_data, "u", "g", weight = "n", se = TRUE, n_bootstrap = 20) at testthat/test_mutual_total.R:47
  2: lapply(1:n_bootstrap, function(i) {
         cat(".")
         resampled <- d[sample(.N, n_total, replace = TRUE, prob = freq)][, list(freq = .N), 
             by = vars]
         mutual_total_compute(resampled, unit, group, within)
     })
  3: FUN(X[[i]], ...)
  4: mutual_total_compute(resampled, unit, group, within)
  5: n_within[, `:=`(n_within = sum(n_within_unit)), by = within]
  6: `[.data.table`(n_within, , `:=`(n_within = sum(n_within_unit)), by = within)
  
  .── 12. Error: zero weights no problem (@test_mutual_total.R#58)  ───────────────
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: expect_equal(dim(mutual_total(test_data, "u", "g", weight = "n", se = TRUE)), c(3, 
         3)) at testthat/test_mutual_total.R:58
  2: quasi_label(enquo(object), label)
  3: eval_bare(get_expr(quo), get_env(quo))
  4: mutual_total(test_data, "u", "g", weight = "n", se = TRUE)
  5: lapply(1:n_bootstrap, function(i) {
         cat(".")
         resampled <- d[sample(.N, n_total, replace = TRUE, prob = freq)][, list(freq = .N), 
             by = vars]
         mutual_total_compute(resampled, unit, group, within)
     })
  6: FUN(X[[i]], ...)
  7: mutual_total_compute(resampled, unit, group, within)
  8: n_within[, `:=`(n_within = sum(n_within_unit)), by = within]
  9: `[.data.table`(n_within, , `:=`(n_within = sum(n_within_unit)), by = within)
  
  ── 13. Error: max bound correct (@test_mutual_total.R#63)  ─────────────────────
  SETLENGTH() cannot be applied to an ALTVEC object.
  1: expect_equal(mutual_total(test_data, "u", "g", weight = "n")[["M", "est"]], log(2)) at testthat/test_mutual_total.R:63
  2: quasi_label(enquo(object), label)
  3: eval_bare(get_expr(quo), get_env(quo))
  4: mutual_total(test_data, "u", "g", weight = "n")
  5: mutual_total_compute(d, unit, group, within)
  6: n_within[, `:=`(n_within = sum(n_within_unit)), by = within]
  7: `[.data.table`(n_within, , `:=`(n_within = sum(n_within_unit)), by = within)
  
  ══ testthat results  ═══════════════════════════════════════════════════════════
  OK: 0 SKIPPED: 0 FAILED: 13
  1. Error: mutual_difference (@test_mutual_diff_mrc.R#16) 
  2. Error: mutual_difference SE (@test_mutual_diff_mrc.R#33) 
  3. Error: mutual_mrc same as mutual_total (@test_mutual_diff_mrc.R#40) 
  4. Error: mutual_mrc same as mutual_total (zero weights) (@test_mutual_diff_mrc.R#62) 
  5. Error: mutual_mrc same both ways (@test_mutual_diff_mrc.R#73) 
  6. Error: mutual_mrc empty cells (@test_mutual_diff_mrc.R#88) 
  7. Error: (unknown) (@test_mutual_local.R#10) 
  8. Error: mutual works both ways around (@test_mutual_total.R#12) 
  9. Error: between + within = total (@test_mutual_total.R#29) 
  1. ...
  
  Error: testthat unit tests failed
  Execution halted