Gabor == Gabor Grothendieck [EMAIL PROTECTED]
on Sun, 21 May 2006 09:47:07 -0400 writes:
Gabor If you know that test is a scalar
Gabor result - if (test) a else b
Gabor will do it.
Yes, indeed!
IMO, ifelse(test, a, b) is much overused where as
if(test) a else b is
On 5/22/2006 3:26 AM, Martin Maechler wrote:
Gabor == Gabor Grothendieck [EMAIL PROTECTED]
on Sun, 21 May 2006 09:47:07 -0400 writes:
Gabor If you know that test is a scalar
Gabor result - if (test) a else b
Gabor will do it.
Yes, indeed!
IMO, ifelse(test, a, b)
Duncan Murdoch wrote:
On 5/22/2006 3:26 AM, Martin Maechler wrote:
Gabor == Gabor Grothendieck [EMAIL PROTECTED]
on Sun, 21 May 2006 09:47:07 -0400 writes:
Gabor If you know that test is a scalar
Gabor result - if (test) a else b
Gabor will do it.
Yes, indeed!
IMO,
If you don't like f(if (temp) a else b)
then what about
temp - if (test) a else b
f(temp)
or
temp - if (test)
a
else
b
f(temp)
I think its easier to understand if you factor the temp- out since
one immediately then knows the purpose of the statement is
to set temp.
On 5/22/06, Duncan
On 5/22/2006 9:38 AM, Frank E Harrell Jr wrote:
Duncan Murdoch wrote:
On 5/22/2006 3:26 AM, Martin Maechler wrote:
Gabor == Gabor Grothendieck [EMAIL PROTECTED]
on Sun, 21 May 2006 09:47:07 -0400 writes:
Gabor If you know that test is a scalar
Gabor result - if (test) a else b
Gabor == Gabor Grothendieck [EMAIL PROTECTED]
on Mon, 22 May 2006 09:31:14 -0400 writes:
Gabor If you don't like f(if (temp) a else b)
Gabor then what about
Gabor temp - if (test) a else b
Gabor f(temp)
Gabor or
Gabor temp - if (test)
Gabor a
Gabor else
Due to lazy evaluation, I don't think a and b are fully evaluated:
ifelse(1, a - 1, b - 2)
[1] 1
a
[1] 1
b
Error: object b not found
On 5/22/06, Martin Maechler [EMAIL PROTECTED] wrote:
Gabor == Gabor Grothendieck [EMAIL PROTECTED]
on Mon, 22 May 2006 09:31:14 -0400 writes:
On Mon, 22 May 2006, Gabor Grothendieck wrote:
Due to lazy evaluation, I don't think a and b are fully evaluated:
ifelse(1, a - 1, b - 2)
[1] 1
a
[1] 1
b
Error: object b not found
yes. If you look at the code for ifelse() it evaluates the second argument
if any test values are TRUE and
On Sun, 21 May 2006, ivo welch wrote:
Aside, I like the flexibility of R, but I am not thrilled by all the
recycling rules. I either mean I want a scalar or a vector of
equal/appropriate dimension. I never want a recycle of a smaller
vector. (I do often use a recycle of a scalar.)
One
TL == Thomas Lumley [EMAIL PROTECTED]
on Mon, 22 May 2006 07:09:09 -0700 (PDT) writes:
TL On Mon, 22 May 2006, Gabor Grothendieck wrote:
Due to lazy evaluation, I don't think a and b are fully evaluated:
ifelse(1, a - 1, b - 2)
[1] 1
a
[1] 1
b
On 5/22/06, Martin Maechler [EMAIL PROTECTED] wrote:
TL == Thomas Lumley [EMAIL PROTECTED]
on Mon, 22 May 2006 07:09:09 -0700 (PDT) writes:
TL On Mon, 22 May 2006, Gabor Grothendieck wrote:
Due to lazy evaluation, I don't think a and b are fully evaluated:
ifelse(1, a -
Gabor Grothendieck wrote:
On 5/22/06, Martin Maechler [EMAIL PROTECTED] wrote:
TL == Thomas Lumley [EMAIL PROTECTED]
on Mon, 22 May 2006 07:09:09 -0700 (PDT) writes:
TL On Mon, 22 May 2006, Gabor Grothendieck wrote:
Due to lazy evaluation, I don't think a and b are fully evaluated:
Gabor == Gabor Grothendieck [EMAIL PROTECTED]
on Mon, 22 May 2006 11:34:09 -0400 writes:
Gabor On 5/22/06, Martin Maechler [EMAIL PROTECTED] wrote:
TL == Thomas Lumley [EMAIL PROTECTED]
on Mon, 22 May 2006 07:09:09 -0700 (PDT) writes:
TL On Mon, 22 May 2006,
Hi Thomas:
One case where the vector-vector recycling rules are used is in
vector-matrix operations:
a-1:4
b-diag(4)
a+b
is this last expression intended to be intuitive and thus desirable?
if anything else, I would end up writing something like this more as
an error than by
On 5/22/2006 5:01 PM, ivo welch wrote:
Hi Thomas:
One case where the vector-vector recycling rules are used is in
vector-matrix operations:
a-1:4
b-diag(4)
a+b
is this last expression intended to be intuitive and thus desirable?
if anything else, I would end up writing
Dear R wizards:
I just got stung by the ifelse() feature.
a - 10:15
b - 20:300
test - 1
ifelse(test,a,b)
[1] 10
I had not realized that this was the default behavior---I had expected
10:15. mea culpa. however, I wonder whether it would make sense to
replace ifelse with a different
If you know that test is a scalar
result - if (test) a else b
will do it. Here is another approach:
as.vector(test * ts(a) + (!test) * ts(b))
On 5/21/06, ivo welch [EMAIL PROTECTED] wrote:
Dear R wizards:
I just got stung by the ifelse() feature.
a - 10:15
b - 20:300
test - 1
ivo welch wrote:
Dear R wizards:
I just got stung by the ifelse() feature.
a - 10:15
b - 20:300
test - 1
ifelse(test,a,b)
[1] 10
I had not realized that this was the default behavior---I had expected
10:15. mea culpa. however, I wonder whether it would make sense to
replace
18 matches
Mail list logo