[R] creating conditional list of elements

murali.menon at uk.abnamro.com murali.menon at uk.abnamro.com
Thu Mar 29 12:40:00 CEST 2007


Sorry to plague the list, but I think I got the answer. The following 
would do:

> signalList <- list(tradingRules$Signal[tradingRules$Enabled]) [[1]]
> length(signalList)
[1] 2

Now my problem is shifted: I have the Signal column in the original data 
frame referring to actual 
matrices previously created in R. That is, bar_signal and cif_signal are 
extant matrices. What I 
need is the minimum number of rows in these matrices, so what I plan to do 
is:

> n <- min(sapply(signalList, NROW))

but this doesn't work (it returns 1, but I have 2800 rows in each of 
bar_signal and cif_signal, so I should
get 2800)

Is there a smart way to do this? And is there a way to tell R that the 
entries in the Signal column 
of tradingSignal are the names of objects?

Thanks,
Murali



Murali Menon/GB/ABNAMRO/NL 
29/03/2007 11:13

To
r-help at stat.math.ethz.ch
cc

Subject
creating conditional list of elements





Folks,

I have a matrix as follows (first column is the rownames, first row is the 
columnnames)

Rule    Enabled Signal
Foo     False           foo_signal
Bar     True            bar_signal
Gum     False           gum_signal
Cif     True            cif_signal

I would like to create a list of only those signals whose 'enabled' flag 
is True. So in the above 
case I should end up with

signalList = bar_signal, cif_signal

Likewise, if the enabled flags were all set to False, then signalList 
should be an empty list.

What's a good way to achieve this, please?

Thanks,

Murali



---------------------------------------------------------------------------
This message (including any attachments) is confidential and...{{dropped}}



More information about the R-help mailing list