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

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: ChannelDistortion
> ### Title: Compute the channel distortion for a given channel and cost
> ###   function.
> ### Aliases: ChannelDistortion
> 
> ### ** Examples
> 
> # Define a discretized Gaussian information source
> x <- seq(from = -10, to = 10, length.out = 100)
> Px <- dnorm(x, mean = 0, sd = 3)
> Px <- Px / sum(Px) # Ensure that probability sums to 1
> y <- x # The destination alphabet is the same as the source
> 
> # Define a quadratic cost function
> cost.function <- function(x, y) {
+     (y - x)^2
+ }
> 
> # Slope of the rate-distortion curve
> s <- -1
> 
> # Compute the rate-distortion value at the given point s
> channel <- BlahutAlgorithm(x, Px, y, cost.function, s)
> 
> # Compute the channel distortion according to a different cost function
> abs.cost.function <- function(x, y) {
+    abs(y - x)
+ }
> 
> ChannelDistortion(channel, abs.cost.function)
 ----------- FAILURE REPORT -------------- 
 --- failure: the condition has length > 1 ---
 --- srcref --- 
: 
 --- package (from environment) --- 
RateDistortion
 --- call from context --- 
ChannelDistortion(channel, abs.cost.function)
 --- call from argument --- 
if (class(channel$x) != "matrix") {
    x <- as.matrix(x)
} else {
    x <- channel$x
}
 --- R stacktrace ---
where 1: ChannelDistortion(channel, abs.cost.function)

 --- value of length: 2 type: logical ---
[1] FALSE  TRUE
 --- function from context --- 
function (channel, rho.fn, ...) 
{
    if (class(channel$x) != "matrix") {
        x <- as.matrix(x)
    }
    else {
        x <- channel$x
    }
    if (class(channel$y) != "matrix") {
        y <- as.matrix(y)
    }
    else {
        y <- channel$y
    }
    nj <- nrow(channel$x)
    nk <- nrow(channel$y)
    D <- 0
    for (j in 1:nj) {
        py <- ConditionalDistribution(channel, j)
        xj <- matrix(data = x[j, ], nrow = nk, ncol = ncol(x), 
            byrow = TRUE)
        D <- D + channel$px[j] * sum(py$p * rho.fn(xj, y, ...))
    }
    D
}
<bytecode: 0x2923198>
<environment: namespace:RateDistortion>
 --- function search by body ---
Function ChannelDistortion in namespace RateDistortion has this body.
 ----------- END OF FAILURE REPORT -------------- 
Error in if (class(channel$x) != "matrix") { : 
  the condition has length > 1
Calls: ChannelDistortion
Execution halted