[EMAIL PROTECTED] wrote:

Hi,

I have the following indexing problem, can you help me please ?

Given:
dm = a data.frame or a matrix dm,
idx = a 2 columns (or any number) matrix with the same number of rows as dm

I want get a subset of dm, for each row, the columns which
specified by idx.

thank you, diana


Diana,
From what I gather it appears as if you want to split dm by all the unique rows of idx? Is that right? If so, you can do the following:


x <- split(dm, do.call("paste", as.data.frame(idx))

This will split dm into a list with each element a subset of dm corresponding to a unique row in idx. The length of the x will be the number of unique rows in idx.

If this is not what you want, please provide an example and what you expect to see.

--sundar

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to