Running examples in 'naivebayes-Ex.R' failed
The error most likely occurred in:

> ### Name: bernoulli_naive_bayes
> ### Title: Bernoulli Naive Bayes Classifier
> ### Aliases: bernoulli_naive_bayes
> 
> ### ** Examples
> 
> # library(naivebayes)
> 
> ### Simulate the data:
> cols <- 10 ; rows <- 100 ; probs <- c("0" = 0.9, "1" = 0.1)
> M <- matrix(sample(0:1, rows * cols,  TRUE, probs), nrow = rows, ncol = cols)
> y <- factor(sample(paste0("class", LETTERS[1:2]), rows, TRUE, prob = c(0.3,0.7)))
> colnames(M) <- paste0("V", seq_len(ncol(M)))
> laplace <- 0
> 
> ### Train the Bernoulli Naive Bayes
> bnb <- bernoulli_naive_bayes(x = M, y = y, laplace = laplace)
> summary(bnb)

============================= Bernoulli Naive Bayes ============================= 
 
- Call: bernoulli_naive_bayes(x = M, y = y, laplace = laplace) 
- Laplace: 0 
- Classes: 2 
- Samples: 100 
- Features: 10 
- Prior probabilities: 
    - classA: 0.28
    - classB: 0.72

--------------------------------------------------------------------------------- 
> 
> # Classification
> head(predict(bnb, newdata = M, type = "class")) # head(bnb %class% M)
[1] classB classB classB classB classB classB
Levels: classA classB
> 
> # Posterior probabilities
> head(predict(bnb, newdata = M, type = "prob")) # head(bnb %prob% M)
         classA    classB
[1,] 0.08558455 0.9144154
[2,] 0.11094760 0.8890524
[3,] 0.19887370 0.8011263
[4,] 0.39836587 0.6016341
[5,] 0.24260388 0.7573961
[6,] 0.38489861 0.6151014
> 
> # Parameter estimates
> coef(bnb)
     classA:0   classA:1  classB:0   classB:1
V1  0.9642857 0.03571429 0.9305556 0.06944444
V2  0.8214286 0.17857143 0.9444444 0.05555556
V3  0.8571429 0.14285714 0.9027778 0.09722222
V4  0.8928571 0.10714286 0.8750000 0.12500000
V5  0.8928571 0.10714286 0.8472222 0.15277778
V6  0.8571429 0.14285714 0.9027778 0.09722222
V7  0.8571429 0.14285714 0.8888889 0.11111111
V8  0.9642857 0.03571429 0.8750000 0.12500000
V9  0.8571429 0.14285714 0.8611111 0.13888889
V10 0.8928571 0.10714286 0.8888889 0.11111111
> 
> 
> ### Sparse data: train the Bernoulli Naive Bayes
> library(Matrix)
> M_sparse <- Matrix(M, sparse = TRUE)
> class(M_sparse) # dgCMatrix
[1] "dgCMatrix"
attr(,"package")
[1] "Matrix"
> 
> # Fit the model with sparse data
> bnb_sparse <- bernoulli_naive_bayes(M_sparse, y, laplace = laplace)
> 
> # Classification
> head(predict(bnb_sparse, newdata = M_sparse, type = "class"))
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'head': 'tcrossprod' is not an exported object from 'namespace:Matrix'
Calls: head ... predict.bernoulli_naive_bayes -> .handleSimpleError -> h
Execution halted