I'm tidying up the gld package at the moment, and the following is my best effort at checking if values are outside the range of the function (which is [0,1] in this case). It seems incredibly messy - is there something better? outside.range <- !as.logical(((p<1)*(p>0))|(sapply(p, all.equal,1)=="TRUE")|(sapply(p, all.equal, 0)=="TRUE")) ---- Robert King, Statistics, School of Mathematical & Physical Sciences, University of Newcastle, Australia Room V133 ph +61 2 4921 5548 Robert.King@newcastle.edu.au http://maths.newcastle.edu.au/~rking/ "It's easy to lie with statistics. It's even easier to lie without them." -- Frederick Mosteller
>>>>> "Robert" == Robert King <robert.king@newcastle.edu.au> >>>>> on Tue, 13 May 2003 10:01:49 +1000 (EST) writes:Robert> I'm tidying up the gld package at the moment, and Robert> the following is my best effort at checking if Robert> values are outside the range of the functi (which is Robert> [0,1] in this case). Robert> It seems incredibly messy - is there something Robert> better? Robert> outside.range <- !as.logical(((p<1)*(p>0))|(sapply(p, Robert> all.equal,1)"TRUE")|(sapply(p, all.equal, 0)"TRUE")) why not just outside.range <- !all(0 <p & p <1) or outside.range <- !all(0 <p) || !all(p <1) or outside.range <- any(p < 0) || any(p > 1) or outside.range <- any(p < 0 | p > 1) {using the double && or || is a short cut and may be faster on average particularly when the first condition is more probable than the fast} Martin
Maybe Matching Threads
- R CMD check fails at package dependencies check on Fedora Core 5, works on other systems
- Assigning functions in Rprofile
- package manual without index? check breaks with - LaTeX errors when creating PDF version.
- Problem with mgcv PACKAGES file format?
- Package installation when $RHOME is not writable (win)