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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: cartogram_cont
> ### Title: Calculate Contiguous Cartogram Boundaries
> ### Aliases: cartogram_cont cartogram_cont.SpatialPolygonsDataFrame
> ###   cartogram_cont.sf
> 
> ### ** Examples
> 
> 
> library(maptools)
Loading required package: sp
Checking rgeos availability: TRUE
> library(cartogram)
> library(rgdal)
rgdal: version: 1.4-7, (SVN revision 845)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 2.4.3, released 2019/10/28
 Path to GDAL shared files: /usr/share/gdal
 GDAL binary built with GEOS: TRUE 
 Loaded PROJ.4 runtime: Rel. 6.2.1, November 1st, 2019, [PJ_VERSION: 621]
 Path to PROJ.4 shared files: (autodetected)
 Linking to sp version: 1.3-2 
> data(wrld_simpl)
> 
> # Remove uninhabited regions
> afr <- spTransform(wrld_simpl[wrld_simpl$REGION==2 & wrld_simpl$POP2005 > 0,], 
+                     CRS("+init=epsg:3395"))
> 
> # Create cartogram
> afr_carto <- cartogram_cont(afr, "POP2005", 3)
Mean size error for iteration 1: 5.21860496451408
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
cartogram
 --- call from context --- 
checkPolygonsGEOS(Polygons(lapply(tmpcoords[[x]], Polygon), rown[x]))
 --- call from argument --- 
if (class(res) == "try-error") {
    warning("Polygons object ", IDs, ", Polygon ", i, ": ", res)
    next
}
 --- R stacktrace ---
where 1: checkPolygonsGEOS(Polygons(lapply(tmpcoords[[x]], Polygon), rown[x]))
where 2: FUN(X[[i]], ...)
where 3: lapply(seq_along(tmpcoords), function(x) checkPolygonsGEOS(Polygons(lapply(tmpcoords[[x]], 
    Polygon), rown[x])))
where 4: stopifnot(is.list(Srl))
where 5: SpatialPolygons(lapply(seq_along(tmpcoords), function(x) checkPolygonsGEOS(Polygons(lapply(tmpcoords[[x]], 
    Polygon), rown[x]))), proj4string = CRS(proj4string(x)))
where 6: cartogram_cont.SpatialPolygonsDataFrame(afr, "POP2005", 3)
where 7: cartogram_cont(afr, "POP2005", 3)

 --- value of length: 2 type: logical ---
[1] FALSE FALSE
 --- function from context --- 
function (obj, properly = TRUE, force = TRUE, useSTRtree = FALSE) 
{
    if (!is(obj, "Polygons")) 
        stop("not a Polygons object")
    if (!requireNamespace("rgeos", quietly = TRUE)) 
        stop("package rgeos required for checkPolygonsGEOS")
    comm <- try(rgeos::createPolygonsComment(obj), silent = TRUE)
    if (class(comm) != "try-error" && !force) {
        comment(obj) <- comm
        return(obj)
    }
    pls <- slot(obj, "Polygons")
    IDs <- slot(obj, "ID")
    n <- length(pls)
    if (n < 1) 
        stop("Polygon list of zero length")
    uniqs <- rep(TRUE, n)
    if (n > 1) {
        if (useSTRtree) 
            tree1 <- rgeos::gUnarySTRtreeQuery(obj)
        SP <- SpatialPolygons(lapply(1:n, function(i) Polygons(list(pls[[i]]), 
            ID = i)))
        for (i in 1:(n - 1)) {
            if (useSTRtree) {
                if (!is.null(tree1[[i]])) {
                  res <- try(rgeos::gEquals(SP[i, ], SP[tree1[[i]], 
                    ], byid = TRUE), silent = TRUE)
                  if (class(res) == "try-error") {
                    warning("Polygons object ", IDs, ", Polygon ", 
                      i, ": ", res)
                    next
                  }
                  if (any(res)) {
                    uniqs[as.integer(rownames(res)[res])] <- FALSE
                  }
                }
            }
            else {
                res <- try(rgeos::gEquals(SP[i, ], SP[uniqs, 
                  ], byid = TRUE), silent = TRUE)
                if (class(res) == "try-error") {
                  warning("Polygons object ", IDs, ", Polygon ", 
                    i, ": ", res)
                  next
                }
                res[i] <- FALSE
                if (any(res)) {
                  wres <- which(res)
                  uniqs[wres[wres > i]] <- FALSE
                }
            }
        }
    }
    if (any(!uniqs)) 
        warning(paste("Duplicate Polygon objects dropped:", paste(wres, 
            collapse = " ")))
    pls <- pls[uniqs]
    n <- length(pls)
    if (n < 1) 
        stop("Polygon list of zero length")
    if (n == 1) {
        oobj <- Polygons(pls, ID = IDs)
        comment(oobj) <- rgeos::createPolygonsComment(oobj)
        return(oobj)
    }
    areas <- sapply(pls, slot, "area")
    pls <- pls[order(areas, decreasing = TRUE)]
    oholes <- sapply(pls, function(x) slot(x, "hole"))
    holes <- rep(FALSE, n)
    SP <- SpatialPolygons(lapply(1:n, function(i) Polygons(list(pls[[i]]), 
        ID = i)))
    if (useSTRtree) 
        tree2 <- rgeos::gUnarySTRtreeQuery(SP)
    for (i in 1:(n - 1)) {
        if (useSTRtree) {
            if (!is.null(tree2[[i]])) {
                if (properly) 
                  res <- rgeos::gContainsProperly(SP[i, ], SP[tree2[[i]], 
                    ], byid = TRUE)
                else res <- rgeos::gContains(SP[i, ], SP[tree2[[i]], 
                  ], byid = TRUE)
            }
            else {
                res <- FALSE
            }
        }
        else {
            if (properly) 
                res <- rgeos::gContainsProperly(SP[i, ], SP[-(1:i), 
                  ], byid = TRUE)
            else res <- rgeos::gContains(SP[i, ], SP[-(1:i), 
                ], byid = TRUE)
        }
        wres <- which(res)
        if (length(wres) > 0L) {
            nres <- as.integer(rownames(res))
            holes[nres[wres]] <- !holes[nres[wres]]
        }
    }
    for (i in 1:n) {
        if (oholes[i] != holes[i]) 
            pls[[i]] <- Polygon(slot(pls[[i]], "coords"), hole = holes[i])
    }
    oobj <- Polygons(pls, ID = IDs)
    comment(oobj) <- rgeos::createPolygonsComment(oobj)
    oobj
}
<bytecode: 0x503e5e8>
<environment: namespace:cartogram>
 --- function search by body ---
Function checkPolygonsGEOS in namespace cartogram has this body.
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1