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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: bbt_run
> ### Title: BBT rating algorithm
> ### Aliases: bbt_run
> 
> ### ** Examples
> 
> # Example from Glickman
> data <- data.frame( name = c( "A", "B", "C", "D" ), 
+                     rank = c( 3, 4, 1, 2 ))
> bbt <- bbt_run( rank ~ name, data )
Warning: LHS of formula doesn't contain `| id` element. It will be assummed that all belongs to the same event id
r is missing and will set to default=25
rd is missing and will set to default=8.33333333333333
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
sport
 --- call from context --- 
bbt_run(rank ~ name, data)
 --- call from argument --- 
if (class(r) != "matrix") r <- as.matrix(r)
 --- R stacktrace ---
where 1: bbt_run(rank ~ name, data)

 --- value of length: 2 type: logical ---
[1] FALSE  TRUE
 --- function from context --- 
function (formula, data, r, rd, sigma, weight, beta = 25/6, kappa = 0.5, 
    gamma, idlab, init_r = 25, init_rd = 25/3, pb = FALSE) 
{
    is_formula_missing(formula)
    is_data_provided(data)
    is_lhs_valid(formula)
    is_rhs_valid(formula, "bbt_run")
    lhs <- all.vars(update(formula, . ~ 0))
    rhs <- all.vars(update(formula, 0 ~ .))
    y <- lhs[1]
    x <- rhs[1]
    id <- ifelse(length(lhs) == 1, "id", lhs[2])
    if (length(lhs) == 1) 
        data$id <- 1
    if (missing(r)) {
        message(paste("r is missing and will set to default="), 
            init_r)
        names <- unique(data[[x]])
        r <- as.matrix(setNames(rep(init_r, length(names)), names))
    }
    if (missing(rd)) {
        message(paste("rd is missing and will set to default="), 
            init_rd)
        names <- unique(data[[x]])
        rd <- as.matrix(setNames(rep(init_rd, length(names)), 
            names))
    }
    if (missing(sigma)) {
        data$sigma <- 0
        sigma <- "sigma"
    }
    if (missing(weight)) {
        data$weight <- 1
        weight <- "weight"
    }
    if (missing(gamma)) 
        gamma <- 999
    if (missing(idlab)) 
        idlab <- id
    if (kappa == 0) 
        kappa = 1e-04
    if (class(r) != "matrix") 
        r <- as.matrix(r)
    if (class(rd) != "matrix") 
        rd <- as.matrix(rd)
    if (any(class(data) == "data.frame")) 
        data_list <- split(data[unique(c(y, id, x, sigma, weight, 
            idlab))], data[[id]])
    n <- length(data_list)
    if (pb) {
        j <- 0
        pb <- txtProgressBar(min = 0, max = n, width = 20, initial = 0, 
            style = 3)
    }
    models <- list()
    for (i in names(data_list)) {
        team_name <- data_list[[i]][[x]]
        model <- bbt(team_name, rank = data_list[[i]][[y]], r = r[team_name, 
            , drop = FALSE], rd = rd[team_name, , drop = FALSE], 
            sigma = data_list[[i]][[sigma]], weight = data_list[[i]][[weight]], 
            kappa = kappa, beta = beta, gamma = gamma, identifier = as.character(data_list[[i]][[idlab]]), 
            init_r = init_r, init_rd = init_rd)
        if (any(!is.finite(model$rd) | !is.finite(model$r) | 
            model$rd < 0)) 
            stop(paste0("Parameters error after evaluating ", 
                id, "=", i), call. = F)
        r[team_name, ] <- model$r[team_name, ]
        rd[team_name, ] <- model$rd[team_name, ]
        models[[i]] <- model
        if (pb) {
            j <- j + 1
            setTxtProgressBar(pb, j)
        }
    }
    model_r <- suppressWarnings(data.table::rbindlist(lapply(models, 
        function(x) x[["r_df"]]), use.names = T, idcol = "id"))
    model_P <- suppressWarnings(data.table::rbindlist(lapply(models, 
        function(x) x[["pairs"]]), use.names = T, idcol = "id"))
    identifierp <- unlist(lapply(models, `[[`, "identifierp"), 
        FALSE, FALSE)
    identifier <- unlist(lapply(models, `[[`, "identifier"), 
        FALSE, FALSE)
    class(model_r[[id]]) <- class(model_P[[id]]) <- class(data[[id]])
    p <- model_P[, .(p_win = prod(P)), by = c("id", "name")][, 
        `:=`(p_win, p_win/sum(p_win)), by = "id"]
    model_r <- merge(model_r, p, all.x = T, by = c("id", "name"), 
        sort = F)
    out <- structure(list(final_r = setNames(as.vector(r), rownames(r)), 
        final_rd = setNames(as.vector(rd), rownames(rd)), r = structure(model_r, 
            identifier = identifier), pairs = structure(model_P, 
            identifier = identifierp)), class = "rating", method = "bbt", 
        formula = formula, settings = list(sigma = sigma, weight = weight, 
            beta = beta, kappa = kappa, gamma = gamma, idlab = idlab, 
            init_r = init_r, init_rd = init_rd))
    return(out)
}
<bytecode: 0x53a3d60>
<environment: namespace:sport>
 --- function search by body ---
Function bbt_run in namespace sport has this body.
 ----------- END OF FAILURE REPORT -------------- 
Error in if (class(r) != "matrix") r <- as.matrix(r) : 
  the condition has length > 1
Calls: bbt_run
Execution halted