Re: [R] avoiding eval parse with indexing: Correction

2013-05-26 Thread Bert Gunter
Yes, for the record, the typo in my earlier post is corrected below. (Martin's previous "correction" both corrected and slightly changed what I provided). -- Bert On Sun, May 26, 2013 at 7:43 AM, Bert Gunter wrote: > Martin: > > Well, assuming I understand, one approach would be to first get th

Re: [R] avoiding eval parse with indexing

2013-05-26 Thread arun
Subject: Re: [R] avoiding eval parse with indexing Hi, You could use: library(abind) #using Berend's and Bert's example x1 <- array(runif(9),dim=c(3,3)) x2 <- array(runif(8),dim=c(2,2,2)) z <- array(1:24,dim=2:4) #applying your code:   eval(parse(text=paste0("x1[1",pa

Re: [R] avoiding eval parse with indexing

2013-05-26 Thread Martin Ivanov
unity! Best regards, Martin > Оригинално писмо >От: arun >Относно: Re: [R] avoiding eval parse with indexing >До: Martin Ivanov >Изпратено на: Неделя, 2013, Май 26 18:48:33 EEST > > >Hi, >You could use: >library(abind) >#using Ber

Re: [R] avoiding eval parse with indexing

2013-05-26 Thread arun
    [,2] #[1,] 0.026671344 0.2116831 #[2,] 0.003903368 0.1551140  asub(z,1,1,drop=TRUE) # [,1] [,2] [,3] [,4] #[1,]    1    7   13   19 #[2,]    3    9   15   21 #[3,]    5   11   17   23 A.K. ----- Original Message - From: Martin Ivanov To: r-help@r-project.org Cc: Sent: Sunday

Re: [R] avoiding eval parse with indexing

2013-05-26 Thread arun
AM Subject: Re: [R] avoiding eval parse with indexing Martin: Well, assuming I understand, one approach would be to first get the dim attribute of the array and then create the appropriate call using that: > z <- array(1:24,dim=2:4) > d <- dim(z) > ix <-lapply(d[-c(1,1)],seq_l

Re: [R] avoiding eval parse with indexing

2013-05-26 Thread Florent D.
library(abind) asub(x, 1, 1) On Sun, May 26, 2013 at 10:43 AM, Bert Gunter wrote: > Martin: > > Well, assuming I understand, one approach would be to first get the > dim attribute of the array and then create the appropriate call using > that: > >> z <- array(1:24,dim=2:4) >> d <- dim(z) >> ix <-

Re: [R] avoiding eval parse with indexing

2013-05-26 Thread Bert Gunter
Martin: Well, assuming I understand, one approach would be to first get the dim attribute of the array and then create the appropriate call using that: > z <- array(1:24,dim=2:4) > d <- dim(z) > ix <-lapply(d[-c(1,1)],seq_len) > do.call("[", c(list(z),1,1,ix)) [1] 1 7 13 19 Is that what you w

Re: [R] avoiding eval parse with indexing

2013-05-26 Thread Berend Hasselman
On 26-05-2013, at 15:56, Martin Ivanov wrote: > Hello, > I would like to get an advice on how the notorious eval(parse()) construct > could possibly > be avoided in the following example. I have an array x, which can have > different number of dimensions, > but I am only interested in extract

[R] avoiding eval parse with indexing

2013-05-26 Thread Martin Ivanov
Hello, I would like to get an advice on how the notorious eval(parse()) construct could possibly be avoided in the following example. I have an array x, which can have different number of dimensions, but I am only interested in extracting, say, the first element of the first dimension. Current