[R] indexing problem
arnaud Gaboury
arnaud.gaboury at gmail.com
Fri May 21 16:29:42 CEST 2010
This maybe a solution. I am currently working with something like :
For (i in length(select)){
posA<-get(paste(c("Pos",select[i]),collapse=""))
posB<-get(paste(c("Pos",select[i+1]),collapse=""))
}
Not yet finalized.
TY for the tip about "select" not to use as an object name
> -----Original Message-----
> From: David Winsemius [mailto:dwinsemius at comcast.net]
> Sent: Friday, May 21, 2010 4:00 PM
> To: arnaud Gaboury
> Cc: r-help at r-project.org
> Subject: Re: [R] indexing problem
>
>
> 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