Running ‘testthat.R’ [7s/12s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > 
  > library(testthat)
  > library(sentometrics)
  Loading required package: data.table
  Loading required package: ggplot2
  Loading required package: foreach
  > 
  > test_check("sentometrics")
  Compute sentiment... Done. 
  Compute sentiment... Done. 
  iteration: 1 from 4
  alphas run: 0.2, 0.7 
  iteration: 2 from 4
  alphas run: 0.2, 0.7 
  iteration: 3 from 4
  alphas run: 0.2, 0.7 
  iteration: 4 from 4
  alphas run: 0.2, 0.7 
  ── 1. Error: (unknown) (@test_attribution.R#25)  ───────────────────────────────
  argument of length 0
  1: retrieve_attributions(out, sentomeasures, do.normalize = FALSE) at testthat/test_attribution.R:25
  2: retrieve_attributions.sentomodeliter(out, sentomeasures, do.normalize = FALSE)
  3: lapply(1:length(refDates), function(d) {
         date <- refDates[d]
         model <- sentomodeliter$models[[d]]
         attribs <- retrieve_attributions(model, sentomeasures, do.normalize = do.normalize, 
             refDates = date, factor = factor)
         return(attribs)
     })
  4: FUN(X[[i]], ...)
  5: retrieve_attributions(model, sentomeasures, do.normalize = do.normalize, refDates = date, 
         factor = factor)
  6: retrieve_attributions.sentomodel(model, sentomeasures, do.normalize = do.normalize, 
         refDates = date, factor = factor)
  7: attribution_docs()
  8: lapply(refDates, function(t) {
         datesIn <- dates[(which(dates %in% t) - nrow(B) + 1):which(dates == t)]
         if (sentomeasures$do.ignoreZeros == FALSE) {
             docWeights <- W[date %in% datesIn, -1:-2]$weights
             fun <- length
         }
         else {
             docWeights <- W[date %in% datesIn, -1:-2]
             fun <- nrow
         }
         if (fun(docWeights) == 0) 
             return("No documents on this date.")
         B$date <- datesIn
         sents <- sent[date %in% datesIn, ]
         sentWeighted <- docWeights * sents[, -1:-3]
         n <- sents[, list(count = .N), by = list(date)]
         sentFull <- lapply(timeNames, function(b) {
             coeffsIn <- coeffs[stringi::stri_detect(cols, regex = paste0("\\b", b))]
             timeWeights <- rep(B[B$date %in% n$date, b], n$count)
             colAttr <- matrix(rep(coeffsIn, sum(n$count)), nrow = sum(n$count), byrow = TRUE) * 
                 timeWeights * sentWeighted
             return(colAttr)
         })
         attribs <- Reduce(`+`, lapply(sentFull, rowSums, na.rm = TRUE))
         out <- data.table(sents[, c("id")], date = sents$date, attrib = attribs)
         return(out)
     })
  9: FUN(X[[i]], ...)
  10: dates[(which(dates %in% t) - nrow(B) + 1):which(dates == t)]
  11: `[.Date`(dates, (which(dates %in% t) - nrow(B) + 1):which(dates == t))
  12: NextMethod("[")
  
  ══ testthat results  ═══════════════════════════════════════════════════════════
  OK: 1 SKIPPED: 0 FAILED: 1
  1. Error: (unknown) (@test_attribution.R#25) 
  
  Error: testthat unit tests failed
  Execution halted