Keith Jewell said:
> ... from reading ?all.equal I would have expected
> scale = 1 and the default scale = NULL to give identical results for the
> length
> one numerics being passed to all.equal.
>
> Can anyone explain?
Inspectng the code in all.equal.numeric, I find
xy <- mean((if (cplx)
On 01/10/2014 23:54, Peter Alspach wrote:
Tena koe Kate
If kateDF is a data.frame with your data, then
apply(kateDF, 1, function(x) isTRUE(all.equal(x[2], x[1], check.attributes =
FALSE, tolerance=0.1)))
comes close to (what I think) you want (but not to what you have illustrated in
your 'ev
> > Is there an easy way to check whether a variable is within +/- 10%
> > range of another variable in R?
You could use
2*abs(A-B)/(A+B) < 0.1
which avoids an apply().
I've assumed you meant different by under 10% of the mean of the two, hence the
2/(A+B); if you meant 10% of something else, s
October 2014 12:39 p.m.
To: Peter Alspach
Cc: r-help
Subject: Re: [R] How to check to see if a variable is within a range of another
variable
Apologise - yes, my 10% calculations seem to be slightly off.
However, the function gives me all falses which seems to be a little
weird. Even wh
Apologise - yes, my 10% calculations seem to be slightly off.
However, the function gives me all falses which seems to be a little
weird. Even where both columns equal each other. Should that be
right?
In essence I want to check whether A and B equal other give or take 10%.
On Wed, Oct 1, 20
Tena koe Kate
If kateDF is a data.frame with your data, then
apply(kateDF, 1, function(x) isTRUE(all.equal(x[2], x[1], check.attributes =
FALSE, tolerance=0.1)))
comes close to (what I think) you want (but not to what you have illustrated in
your 'eventual outcome'). Anyhow, it may be enough
On Wed, Oct 1, 2014 at 3:11 PM, Kate Ignatius wrote:
> Is there an easy way to check whether a variable is within +/- 10%
> range of another variable in R?
Yes,
checkRange = function(A, B, range = 0.1)
{
A>=B*(1-range) & A<=B*(1+range);
}
Test:
A = c(67, 24, 40, 10, 70, 101, 9)
B = c(76, 23
7 matches
Mail list logo