On 26-05-2013, at 15:56, Martin Ivanov <tra...@abv.bg> 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 extracting, say, the first element of the first > dimension. Currently I achieve this > in this way: > > eval(parse(text=paste0("x[1", paste(rep(", ", length(dim(x)) - 1), > collapse=""), "]"))) > > Is it possible to avoid the eval parse here? How?
I tried this x1 <- array(runif(9),dim=c(3,3)) x2 <- array(runif(8),dim=c(2,2,2)) and then x1[1] and x2[1] gave me what you wanted. I don't know if it is the coRRect way to do what you want. Berend ______________________________________________ R-help@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.