# NOT RUN {
##
## 1. equal
##
# }
# NOT RUN {
all.equal(compareLengths(1:3, 4:6), c("equal", ''))
# }
# NOT RUN {
##
## 2. compatible
##
a <- 1:2
b <- letters[1:6]
comp.ab <- compareLengths(a, b, message0='Chk:')
comp.ba <- compareLengths(b, a, message0='Chk:')
# check
chk.ab <- c('compatible',
'Chk: length(b) = 6 is 3 times length(a) = 2')
# }
# NOT RUN {
all.equal(comp.ab, chk.ab)
# }
# NOT RUN {
all.equal(comp.ba, chk.ab)
# }
# NOT RUN {
##
## 3. incompatible
##
Z <- LETTERS[1:3]
comp.aZ <- compareLengths(a, Z)
# check
chk.aZ <- c('incompatible',
' length(Z) = 3 is not a multiple of length(a) = 2')
# }
# NOT RUN {
all.equal(comp.aZ, chk.aZ)
# }
# NOT RUN {
##
## 4. problems with name.x and name.y
##
comp.ab2 <- compareLengths(a, b, '', '')
# check
chk.ab2 <- c('compatible',
'in compareLengths: length(y) = 6 is 3 times length(x) = 2')
# }
# NOT RUN {
all.equal(comp.ab2, chk.ab2)
# }
# NOT RUN {
##
## 5. zeroLength
##
zeroLen <- compareLengths(logical(0), 1)
# check
zeroL <- c('compatible', ' length(logical(0)) = 0')
# }
# NOT RUN {
all.equal(zeroLen, zeroL)
# }
Run the code above in your browser using DataLab