Displaying 2 results from an estimated 2 matches for "roundsjeremiah".
2017 Dec 13
0
difference between ifelse and if...else?
ifelse is vectorized.
On Wed, Dec 13, 2017 at 7:31 AM, Jinsong Zhao <jszhao at yeah.net> wrote:
> Hi there,
>
> I don't know why the following codes are return different results.
>
> > ifelse(3 > 2, 1:3, length(1:3))
> [1] 1
> > if (3 > 2) 1:3 else length(1:3)
> [1] 1 2 3
>
> Any hints?
>
> Best,
> Jinsong
>
>
2017 Dec 13
4
difference between ifelse and if...else?
Hi there,
I don't know why the following codes are return different results.
> ifelse(3 > 2, 1:3, length(1:3))
[1] 1
> if (3 > 2) 1:3 else length(1:3)
[1] 1 2 3
Any hints?
Best,
Jinsong