[R] indexing problem

David Winsemius dwinsemius at comcast.net
Fri May 21 15:59:56 CEST 2010


On May 21, 2010, at 9:19 AM, arnaud Gaboury wrote:

> Dear group,
>
> Here is my environment :
>
>> ls()
> [1] "l"          "PLglobal"   "Pos100415"  "Pos100416"  "Pos100419"
> "Pos100420"  "position"   "select"     "Trad100415" "Trad100416"
> "Trad100419" "Trad100420" "trade"      "y"
>
> With objects :
>
>> l
> [1] "100415" "100416" "100419" "100420" "100421" "100422" "100423"  
> "100426"
> "100427" "100428" "100429" "100430" "100503" "100504" "100505"  
> "100506"
> "100507" "100510" "100511" "100512" "100513"
>
>> select    #is a selection of elements of object "l"
> [1] "100415" "100416" "100419" "100420"
>
> "PLglobal", "position", "trade" are all functions
> Pos100415,Pos100416,Trad100415...are all data frames
>
> I have one dataframe each day. For example, Pos100415 is "Pos" for day
> 15/04/2010.
>
> Now I need to access data.frames in my environment for a function,  
> according
> to this following scheme:
>
> Pos100415 and Pos100416 (i.e. Pos(day1) and Pos(day2)), and  
> Trad100416 (i.e.
> trad(day2)).
>
> I have absolutely no idea how to deal with this indexing problem in a
> generic manner. Note that all numbers will belong to the list  
> "select".

Sounds like you need to have one Positions dataframe and one Trades  
dataframe rather than leaving them separate. Then you would be  
indexing by day and if needed the subset function could parcel out  
particular day-defined subsets. I would not use the object name  
"select" since it is one of the argument names for subset.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list