Skip to content
Back to formatted view

Raw Message

Message-ID: <BANLkTi=1qqTBfs5=Ma-PmK3N=e28fdL9AQ@mail.gmail.com>
Date: 2011-06-18T14:57:50Z
From: jim holtman
Subject: Array
In-Reply-To: <alpine.LRH.2.02.1106181541260.9165@finland.ouce.ox.ac.uk>

Try using 'if':

> s  <- 1
> a1 <- array(dim=c(1,4))
> a2 <- array(dim=c(2,4))
> arr <- if (s == 1) a1 else a2
> str(arr)
 logi [1, 1:4] NA NA NA NA
>


On Sat, Jun 18, 2011 at 10:45 AM, Muhammad Rahiz
<muhammad.rahiz at ouce.ox.ac.uk> wrote:
> Hi,
> Can someone advise why the followind did not produce the array, given the
> condition specified?
>
> s ?<- 1
> a1 <- array(dim=c(1,4))
> a2 <- array(dim=c(2,4))
> arr <- ifelse(s==0,a1,a2)
>
> Thanks.
>
> Muhammad
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?