> S community,
>
> I am using expand.grid to flexibly create a set of cell indexes(i,,j) from
> the dimensions of any matrix passed to a function.
>
> How can I get the expand.grid output into the form of a list of vectors?
>
> e.g list of cell index vectors
> [[1]]:
> [1] 1 1
>
> [[2]]:
> [1] 1 2
>
> [[3]]:
> [1] i j
>
> Here is my case
>
> #Get dimensions of any matrix or array
> idx.limits <-dim(acube)
>
> #Generate the list of (planar) central cell index combinations
> ccidx <- expand.grid (1:idx.limits[1], 1:idx.limits[2])
>
> I can try...
> ccidx.matrix <- matrix(c(ccidx[[1]], ccidx[[2]]), length(ccidx[[1]]))
>
> to get a matrix, and then ...
> ccidx.list <- apply(ccidx.matrix, 1, c)
>
> to collapse along the rows, But c doesn't work as expected. Sum adds along
> rows, but concatenate doesn't work that way?
>
> D. Brent Myers
> Research Specialist - Agronomy
> University of Missouri
> 158 Ag Engineering Building
> Columbia, MO 65211
>
>
>
|