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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: boe
> ### Title: Parameters for MPC CPI Inflation Projections from Q1 2004 to Q4
> ###   2013.
> ### Aliases: boe
> ### Keywords: datasets
> 
> ### ** Examples
> 
> ##
> ##Q1 2013
> ##
> #extract data for Q1 2013
> y0 <- 2013
> boe0<-subset(boe, time0==y0)
> k <- nrow(boe0)
> 
> #guess work to set percentiles the boe are plotting
> p <- seq(0.05, 0.95, 0.05)
> p <- c(0.01, p, 0.99)
> 
> #estimate percentiles for future time period
> pp <- matrix(NA, nrow = length(p), ncol = k)
> for (i in 1:k)
+   pp[, i] <- qsplitnorm(p, mode = boe0$mode[i], sd = boe0$uncertainty[i], skew = boe0$skew[i])
> pp
          [,1]      [,2]      [,3]      [,4]       [,5]       [,6]       [,7]
 [1,] 1.310928 0.8728139 0.6377539 0.1755382 -0.1673062 -0.3670966 -0.7036235
 [2,] 1.726639 1.4725288 1.3942125 1.0410359  0.7458961  0.5665505  0.2436535
 [3,] 1.948254 1.7922346 1.7974778 1.5024295  1.2327209  1.0642744  0.7486433
 [4,] 2.097776 2.0079386 2.0695589 1.8137296  1.5611793  1.4000863  1.0893576
 [5,] 2.216611 2.1793733 2.2858004 2.0611410  1.8222275  1.6669789  1.3601465
 [6,] 2.318561 2.3264490 2.4713164 2.2733980  2.0461837  1.8959490  1.5924592
 [7,] 2.410116 2.4585275 2.6379154 2.4640113  2.2473033  2.1015713  1.8010833
 [8,] 2.494955 2.5809180 2.7922943 2.6406430  2.4336706  2.2921110  1.9944046
 [9,] 2.575458 2.6970545 2.9387847 2.8082492  2.6105149  2.4729145  2.1778475
[10,] 2.653347 2.8094180 3.0805159 2.9704101  2.7816138  2.6478440  2.3553307
[11,] 2.730000 2.9200000 3.2200000 3.1300000  2.9500000  2.8200000  2.5300000
[12,] 2.806653 3.0305820 3.3594841 3.2895899  3.1183862  2.9921560  2.7046693
[13,] 2.884542 3.1429455 3.5012153 3.4517508  3.2894851  3.1670855  2.8821525
[14,] 2.965045 3.2590820 3.6477057 3.6193570  3.4663294  3.3478890  3.0655954
[15,] 3.049884 3.3814725 3.8020846 3.7959887  3.6526967  3.5384287  3.2589167
[16,] 3.141439 3.5135510 3.9686836 3.9866020  3.8538163  3.7440510  3.4675408
[17,] 3.243389 3.6606267 4.1541996 4.1988590  4.0777725  3.9730211  3.6998535
[18,] 3.362224 3.8320614 4.3704411 4.4462704  4.3388207  4.2399137  3.9706424
[19,] 3.511746 4.0477654 4.6425222 4.7575705  4.6672791  4.5757256  4.3113567
[20,] 3.733361 4.3674712 5.0457875 5.2189641  5.1541039  5.0734495  4.8163465
[21,] 4.149072 4.9671861 5.8022461 6.0844618  6.0673062  6.0070966  5.7636235
             [,8]       [,9]      [,10]      [,11]       [,12]       [,13]
 [1,] -0.89341398 -1.1229949 -1.2362583 -1.3595218 -1.52604877 -1.57604877
 [2,]  0.07430785 -0.1143834 -0.2208319 -0.3372804 -0.49017751 -0.54017751
 [3,]  0.59019678  0.4233037  0.3204882  0.2076727  0.06204162  0.01204162
 [4,]  0.93826459  0.7860786  0.6857142  0.5753499  0.43462125  0.38462125
 [5,]  1.21489785  1.0744006  0.9759844  0.8675681  0.73073572  0.68073572
 [6,]  1.45222455  1.3217552  1.2250103  1.1182654  0.98477558  0.93477558
 [7,]  1.66535127  1.5438872  1.4486432  1.3433992  1.21291122  1.16291122
 [8,]  1.86284494  1.7497257  1.6558725  1.5520193  1.42431289  1.37431289
 [9,]  2.05024711  1.9450463  1.8525128  1.7499793  1.62491240  1.57491240
[10,]  2.23156089  2.1340212  2.0427646  1.9415080  1.81899475  1.76899475
[11,]  2.41000000  2.3200000  2.2300000  2.1300000  2.01000000  1.96000000
[12,]  2.58843911  2.5059788  2.4172354  2.3184920  2.20100525  2.15100525
[13,]  2.76975289  2.6949537  2.6074872  2.5100207  2.39508760  2.34508760
[14,]  2.95715506  2.8902743  2.8041275  2.7079807  2.59568711  2.54568711
[15,]  3.15464873  3.0961128  3.0113568  2.9166008  2.80708878  2.75708878
[16,]  3.36777545  3.3182448  3.2349897  3.1417346  3.03522442  2.98522442
[17,]  3.60510215  3.5655994  3.4840156  3.3924319  3.28926428  3.23926428
[18,]  3.88173541  3.8539214  3.7742858  3.6846501  3.58537875  3.53537875
[19,]  4.22980322  4.2166963  4.1395118  4.0523273  3.95795838  3.90795838
[20,]  4.74569215  4.7543834  4.6808319  4.5972804  4.51017751  4.46017751
[21,]  5.71341398  5.7629949  5.6962583  5.6195218  5.54604877  5.49604877
> 
> #plot cpi
> par(mar=rep(2,4))
> plot(cpi, type = "l", xlim = floor(c(y0-5, y0+3)), ylim = c(-2, 7), las = 1, 
+  col="tomato", lwd=2, xaxt = "n", yaxt = "n")
> 
> #backround
> rect(y0-0.25, par("usr")[3] - 1, y0+3, par("usr")[4] + 1, border = "gray90", col = "gray90")
> 
> #fan
> pal <- colorRampPalette(c("tomato", "gray90"))
> fan(data=pp, probs=p, sim.data=FALSE, start=y0, frequency=4, 
+  anchor=cpi[time(cpi)==y0-0.25], fan.col=pal, ln=NULL, rlab=FALSE)
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
fanplot
 --- call from context --- 
fan(data = pp, probs = p, sim.data = FALSE, start = y0, frequency = 4, 
    anchor = cpi[time(cpi) == y0 - 0.25], fan.col = pal, ln = NULL, 
    rlab = FALSE)
 --- call from argument --- 
if (class(data) != "zoo") {
    ppts <- ts(pp, start = start, frequency = frequency)
    tt <- time(ppts)
    tt <- as.numeric(tt)
    if (!is.null(anchor)) {
        ppts <- ts(pp, start = time(lag(ppts))[1], frequency = frequency)
        tt <- time(ppts)
        tt <- as.numeric(tt)
    }
}
 --- R stacktrace ---
where 1: fan(data = pp, probs = p, sim.data = FALSE, start = y0, frequency = 4, 
    anchor = cpi[time(cpi) == y0 - 0.25], fan.col = pal, ln = NULL, 
    rlab = FALSE)

 --- value of length: 2 type: logical ---
[1] TRUE TRUE
 --- function from context --- 
function (data = NULL, data.type = "simulations", style = "fan", 
    type = "percentile", probs = if (type == "percentile") seq(0.01, 
        0.99, 0.01) else c(0.5, 0.8, 0.95), start = 1, frequency = 1, 
    anchor = NULL, anchor.time = NULL, fan.col = heat.colors, 
    alpha = if (style == "spaghetti") 0.5 else 1, n.fan = NULL, 
    ln = if (length(probs) < 10) probs else probs[round(probs, 
        2) %in% round(seq(0.1, 0.9, 0.1), 2)], ln.col = if (style == 
        "spaghetti") "gray" else NULL, med.ln = if (type == "interval") TRUE else FALSE, 
    med.col = "orange", rlab = ln, rpos = 4, roffset = 0.1, rcex = 0.8, 
    rcol = NULL, llab = FALSE, lpos = 2, loffset = roffset, lcex = rcex, 
    lcol = rcol, upplab = "U", lowlab = "L", medlab = if (type == 
        "interval") "M" else NULL, n.spag = 30, space = if (style == 
        "boxplot") 1/frequency else 0.9/frequency, add = FALSE, 
    ylim = range(data) * 0.8, ...) 
{
    if (add == TRUE) 
        plot(data[, 1], type = "n", ylim = ylim, ...)
    if (!(data.type %in% c("values", "simulations"))) 
        stop("data.type must be set to one of: values, simulations")
    if (!(style %in% c("fan", "boxfan", "spaghetti", "boxplot"))) 
        stop("style must be set to one of: fan, boxfan, spaghetti or boxplot")
    if (class(data)[1] == "mts") {
        start <- start(data)[1]
        frequency <- frequency(data)
    }
    if (style == "fan" | style == "boxfan" | style == "spaghetti") {
        if (!(type %in% c("percentile", "interval"))) 
            stop("type must be set to one of: percentile or interval")
        p <- probs
        if (min(p) < 0 | max(p) > 100) 
            stop("all probs must be between 0 and 1 (or 0 and 100)")
        if (max(p) > 1) 
            p <- p/100
        if (type == "percentile") 
            p <- c(p, 1 - p)
        if (type == "interval" & data.type == "simulations") 
            p <- c(p + (1 - p)/2, 1 - p - (1 - p)/2)
        p <- round(p, 5)
        p <- sort(unique(p))
        if (data.type == "simulations") {
            pp <- as.matrix(data)
            pp <- apply(pp, 2, quantile, probs = p)
        }
        if (data.type == "values") {
            pp <- as.matrix(data)
            if (type == "percentile" & length(p) != nrow(pp)) 
                stop("probs must correspond to the nrows of data if data.type==values and type is percentile")
            if (type == "interval" & length(probs) != 2 * nrow(pp)) {
                p <- probs
                p <- c(p + (1 - p)/2, 1 - p - (1 - p)/2)
                p <- sort(p)
                p <- round(p, 5)
            }
        }
        n <- nrow(pp)
        if (type == "interval") {
            rownames(pp) <- paste0(rep(c(lowlab, upplab), each = n/2), 
                200 * abs(0.5 - p), "%")
        }
        if (!is.null(anchor)) {
            pp <- cbind(rep(anchor, n), pp)
        }
        pp <- t(pp)
        if (class(data) != "zoo") {
            ppts <- ts(pp, start = start, frequency = frequency)
            tt <- time(ppts)
            tt <- as.numeric(tt)
            if (!is.null(anchor)) {
                ppts <- ts(pp, start = time(lag(ppts))[1], frequency = frequency)
                tt <- time(ppts)
                tt <- as.numeric(tt)
            }
        }
        if (class(data) == "zoo") {
            tt <- time(data)
            if (!is.null(anchor)) 
                tt <- c(anchor.time, tt)
        }
    }
    if (style == "fan" | style == "boxfan") {
        if (is.null(n.fan)) 
            fan.col <- fan.col(floor(n/2))
        if (!is.null(n.fan)) 
            fan.col <- fan.col(n.fan)
        fan.col <- adjustcolor(fan.col, alpha.f = alpha)
        if (is.null(ln.col)) 
            ln.col <- fan.col[1]
    }
    if (style == "fan") {
        fan.fill <- function(ts1, ts2, tt, fan.col = "grey") {
            xx <- cbind(tt, rev(tt))
            yy <- cbind(as.vector(ts1), rev(as.vector(ts2)))
            polygon(xx, yy, col = fan.col, border = fan.col)
        }
        for (i in 1:floor(n/2)) {
            fan.fill(ts1 = pp[, i], ts2 = pp[, n - i + 1], tt = tt, 
                fan.col = fan.col[floor(n/2) + 1 - i])
        }
    }
    if (style == "boxfan") {
        x <- pp[, 1]
        for (i in 1:nrow(pp)) {
            for (j in 1:floor(n/2)) {
                rect(xleft = tt[i] - 0.5 * space, ybottom = pp[i, 
                  j], xright = tt[i] + 0.5 * space, ytop = pp[i, 
                  n - j + 1], col = fan.col[floor(n/2) + 1 - 
                  j], border = fan.col[floor(n/2) + 1 - j])
            }
        }
    }
    if (style == "fan" | style == "boxfan") {
        ln0 <- ln
        if (!is.null(ln0)) {
            if (min(ln0) < 0 | max(ln0) > 100) 
                stop("all ln must be between 0 and 1 (or 0 and 100)")
            if (max(ln0) > 1) 
                ln0 <- ln0/100
            if (type == "interval") {
                ln0 <- c(ln0 + (1 - ln0)/2, 1 - ln0 - (1 - ln0)/2)
                ln0 <- sort(ln0)
            }
            ln0 <- round(ln0, 5)
            if (style == "fan") {
                for (i in match(ln0, p)) lines(x = tt, y = pp[, 
                  i], col = ln.col)
            }
            if (style == "boxfan") {
                for (i in 1:nrow(pp)) {
                  for (j in match(ln0, p)) {
                    lines(x = tt[i] + c(-0.5, 0.5) * space, y = rep(pp[i, 
                      j], 2), col = ln.col)
                  }
                }
            }
            if (is.na(sum(match(ln0, p)))) 
                print("some lines not plotted as conflict with precentiles given in probs")
        }
    }
    if (style == "fan" | style == "boxfan") {
        if (data.type == "values" & type == "percentile") 
            colnames(pp) <- paste0(p * 100, "%")
        if (!is.null(rlab)) {
            if (min(rlab) < 0 | max(rlab) > 100) 
                stop("all rlab must be between 0 and 1 (or 0 and 100)")
            if (max(rlab) > 1) 
                rlab <- rlab/100
            if (type == "interval") 
                rlab <- c(rlab + (1 - rlab)/2, 1 - rlab - (1 - 
                  rlab)/2)
            rlab <- sort(rlab)
            rlab <- round(rlab, 5)
            for (i in match(rlab, p)) {
                if (style == "fan") 
                  text(tt[length(tt)], pp[nrow(pp), i], colnames(pp)[i], 
                    pos = rpos, offset = roffset, cex = rcex, 
                    col = rcol)
                if (style == "boxfan") 
                  text(tt[length(tt)] + 0.5 * space, pp[nrow(pp), 
                    i], colnames(pp)[i], pos = rpos, offset = roffset, 
                    cex = rcex, col = rcol)
            }
            if (is.na(sum(match(rlab, p)))) 
                print("some right labels not plotted as conflict with precentiles given in probs")
        }
        if (is.numeric(llab[1]) | llab[1] == TRUE) {
            if (is.numeric(llab[1])) {
                if (min(llab) < 0 | max(llab) > 100) 
                  stop("all llab must be between 0 and 1 (or 0 and 100)")
                if (max(llab) > 1) 
                  llab <- llab/100
                if (type == "interval") 
                  llab <- c(llab + (1 - llab)/2, 1 - llab - (1 - 
                    llab)/2)
                llab <- sort(llab)
                llab <- round(llab, 5)
            }
            if (llab[1] == TRUE) 
                llab <- rlab
            for (i in match(llab, p)) {
                if (style == "fan") 
                  text(tt[1], pp[1, i], colnames(pp)[i], pos = lpos, 
                    offset = loffset, cex = lcex, col = lcol)
                if (style == "boxfan") 
                  text(tt[1] - 0.5 * space, pp[1, i], colnames(pp)[i], 
                    pos = lpos, offset = loffset, cex = lcex, 
                    col = lcol)
            }
            if (is.na(sum(match(llab, p)))) 
                print("some left labels not plotted as conflict with precentiles given in probs")
        }
    }
    if (style == "fan" | style == "boxfan") {
        if (med.ln == TRUE & data.type == "simulations") {
            pp <- data
            pm <- apply(pp, 2, median)
            if (!is.null(anchor)) 
                pm <- c(anchor, pm)
            if (is.null(med.col)) 
                med.col <- ln.col
            if (style == "fan") {
                lines(x = tt, y = pm, col = med.col)
            }
            if (style == "boxfan") {
                for (i in 1:nrow(pp)) {
                  lines(x = tt[i] + c(-0.5, 0.5) * space, y = rep(pm[i], 
                    2), col = med.col)
                }
            }
            if (!is.null(rlab) & style %in% c("fan", "spaghetti")) 
                text(tt[length(tt)], pm[length(pm)], medlab, 
                  pos = rpos, offset = roffset, cex = rcex, col = rcol)
            if (!is.null(rlab) & style == "boxfan") 
                text(tt[length(tt)] + 0.5 * space, pm[length(pm)], 
                  medlab, pos = rpos, offset = roffset, cex = rcex, 
                  col = rcol)
            if (any(llab == TRUE, is.numeric(llab)) & style %in% 
                c("fan", "spaghetti")) 
                text(tt[1], pm[1], medlab, pos = lpos, offset = loffset, 
                  cex = lcex, col = lcol)
            if (any(llab == TRUE, is.numeric(llab)) & style == 
                "boxfan") 
                text(tt[1] - 0.5 * space, pm[1], medlab, pos = lpos, 
                  offset = loffset, cex = lcex, col = lcol)
        }
    }
    if (style == "spaghetti") {
        ps <- as.matrix(data)
        n <- nrow(ps)
        ps <- ps[sample(1:n, n.spag), ]
        if (!is.null(anchor)) 
            ps <- cbind(rep(anchor, nrow(ps)), ps)
        spag.col <- adjustcolor(ln.col, alpha.f = alpha)
        for (i in 1:nrow(ps)) lines(x = tt, y = ps[i, ], col = spag.col)
    }
    if (style == "boxplot") {
        if (data.type == "values") 
            stop(print("data must be simulations"))
        pp <- data
        n <- ncol(pp)
        if (!is.null(anchor)) 
            print("anchor ignored for boxplots plots")
        p <- ts(pp[1, ], start = start, frequency = frequency)
        for (i in 1:n) boxplot(pp[, i], add = TRUE, at = time(p)[i], 
            boxwex = space, xaxt = "n", yaxt = "n", ...)
    }
    box()
}
<bytecode: 0x1ab94a0>
<environment: namespace:fanplot>
 --- function search by body ---
Function fan in namespace fanplot has this body.
 ----------- END OF FAILURE REPORT -------------- 
Fatal error: the condition has length > 1