Once you have this matrix:
mx <- cbind(x1, x2, x3, x4)
> > x1 x2 x3 x4
> > [1,] 22 14 24 10
> > [2,] 27 12 1 2
> > [3,] 23 13 6 2
> > [4,] 27 6 21 2
> > [5,] 14 29 12 19
> > [6,] 5 14 11 29
> > [7,] 10 10 27 25
> > [8,] 16 29 28 10
> > [9,] 22 22 19 7
> > [10,] 30 20 5 22
> > [11,] 2
1,res2)
#[1] TRUE
identical(res1,res3)
#[1] TRUE
identical(res1,res4)
#[1] TRUE
identical(res1,res4New)
#[1] TRUE
A.K.
- Original Message -
From: Brian Perron
To: r-help@r-project.org
Cc:
Sent: Wednesday, June 19, 2013 9:24 AM
Subject: [R] alternative to ifelse
Greetings:
I
On Jun 19, 2013, at 1:23 PM, Marc Schwartz wrote:
>
> On Jun 19, 2013, at 8:24 AM, Brian Perron wrote:
>
>> Greetings:
>>
>> I am looking for a way to avoid using the ifelse function for
>> constructing a new variable. More specifically, assume I have a set
>> of variables with scores rangi
On Jun 19, 2013, at 1:23 PM, Marc Schwartz wrote:
>
> On Jun 19, 2013, at 8:24 AM, Brian Perron wrote:
>
>> Greetings:
>>
>> I am looking for a way to avoid using the ifelse function for
>> constructing a new variable. More specifically, assume I have a set
>> of variables with scores rangi
On Jun 19, 2013, at 8:24 AM, Brian Perron wrote:
> Greetings:
>
> I am looking for a way to avoid using the ifelse function for
> constructing a new variable. More specifically, assume I have a set
> of variables with scores ranging from 1 to 30.
>
> set.seed(12345)
> x <- c(1:30)
> x1 <- sam
On Jun 19, 2013, at 8:24 AM, Brian Perron wrote:
> Greetings:
>
> I am looking for a way to avoid using the ifelse function for
> constructing a new variable. More specifically, assume I have a set
> of variables with scores ranging from 1 to 30.
>
> set.seed(12345)
> x <- c(1:30)
> x1 <- sam
On Wed, 19 Jun 2013, Brian Perron writes:
> Greetings:
>
> I am looking for a way to avoid using the ifelse function for
> constructing a new variable. More specifically, assume I have a set
> of variables with scores ranging from 1 to 30.
>
> set.seed(12345)
> x <- c(1:30)
> x1 <- sample(x, 15,
as.numeric(x1 == 1 | x2 == 1 | x3 == 1 | x4 == 1)
On Wed, Jun 19, 2013 at 9:24 AM, Brian Perron wrote:
> Greetings:
>
> I am looking for a way to avoid using the ifelse function for
> constructing a new variable. More specifically, assume I have a set
> of variables with scores ranging from 1 t
Greetings:
I am looking for a way to avoid using the ifelse function for
constructing a new variable. More specifically, assume I have a set
of variables with scores ranging from 1 to 30.
set.seed(12345)
x <- c(1:30)
x1 <- sample(x, 15, replace = TRUE)
x2 <- sample(x, 15, replace = TRUE)
x3 <- s
9 matches
Mail list logo