[correcting a stupid error in my previous post]
testTwoStages <- function(x, y, head.stop = 100){
if(!isTRUE(all(head(x, head.stop) == head(y, head.stop))))
{
print(paste("quick test returned FALSE"))
return(FALSE)
} else {
full.test = isTRUE(all(tail(x, length(x) - head.stop) == tail(y,
length(y) - head.stop)))
print(paste("full test returned", full.test))
return(full.test)
}
}
x <- seq(1, 1e6)
y <- x
y[325] <- 0
system.time(testTwoStages(x, y)) # FALSE and slow
system.time(testTwoStages(x, y, 400)) # FALSE and quick
system.time(testTwoStages(x, x)) # TRUE and slow
--
_____________________________
Baptiste AuguiƩ
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.