[R] Combining values from a data.frame row with matrix rownames.

Gil Gamesh gamesh.g at gmail.com
Tue Aug 17 19:36:34 CEST 2010


Apologies, I neglected to check that the email was plain text. Here is
a the text of the previous email.


Hello,

I am trying to iteratively build a build a panel of variables to
discriminate between two groups.

My starting position is a matrix of experimental data and I have a function
that will work through all pairs of variables and produce sensitivities,
specificities and p-values for each pair and write it to a file (above
particular cut-offs).

I have a second function that will read that file in and use the pairs as a
'seed' adding a third variable from the original matrix and performing the
same calculations and writing a new file.

My aim is to iterate through this procedure five or six times.

My difficulty is making the index vector to extract the values I need from
the matrix of experimental data.

The seed panel is a row in a data.frame:

print(seed_panel[i,])

      V2     V3
1 507D22 518F15


and the variable to add to it is a rowname of the experimental matrix:

print(rownames(Control[j,]))

[1] "505E01"

I haven't found a way to combine these three - I would like a vector
c("507D22","518F15","505E01") - to subscript the matrix of experimental
data.

IndexList <- c(as.vector( seed_panel[ i, ], mode="any"), rownames( Control[
j, ] ) )

Gives:

$V2
[1] 507D22
18 Levels: 507D22 518F15 522C17 522K21 523A19 528H06 528P11 530H18 ...
585K18

$V3
[1] 518F15
20 Levels: 518F15 522C17 522K21 523A19 528H06 528P11 530H18 534L09 ...
590C18

[[3]]
[1] "505E01"

and I haven't had any luck with variations on this that I've tried.


Many thanks in advance for any help.



More information about the R-help mailing list