Adding a column to a data frame can be done without copying in several
languages, since all one needs is to maintain a list of pointers to the
columns. You suggested I add a column of integers (the indices), which is
the logical approach, but for very large data frames, it is a waste of
memory and time. However, it works.

    Gordon


On Mon, Apr 30, 2012 at 3:45 PM, Gordon Erlebacher <
gordon.erlebach@gmail.com> wrote:

> Hi Jeff,
>
> You cannot insert an element within an array without copying. But let us
> do something simpler:
>
> df = data.frame(a=1:10, b=101:110)
>
> a = df[5:10]
>
> This can be done without copying in several languages. Not R (as far as I
> know). In R, almost everything is done without copying, even when copying
> is not really required. On the other hand, R has many nice properties.
>
>      Gordon
>
>
>
> On Mon, Apr 30, 2012 at 3:43 PM, Joshua Ulrich <josh.m.ulrich@gmail.com>wrote:
>
>> Please reply to the list, so others can benefit.
>>
>> On Mon, Apr 30, 2012 at 1:07 PM, Gordon Erlebacher
>> <gordon.erlebach@gmail.com> wrote:
>> > Yes, I have used that technique. Do not like it because the cya
>> structure
>> > must be copied, inefficient. I try to minimize copies. It is obvious to
>> me
>> > that r maintains this index column, internally perhaps. I will adopt
>> your
>> > approach then. Thanks.   Gordon.
>> >
>> Can you explain how would it be possible to insert a new element into
>> a sorted array without copying?  It's not clear to me how you could do
>> this in any language.
>>
>> The index in xts/zoo objects is an attribute attached to an underlying
>> matrix object.  It is not possible for the index to have a different
>> number of elements than rows in the underlying matrix.
>>
>> > On Apr 30, 2012 1:42 PM, "Joshua Ulrich" <josh.m.ulrich@gmail.com>
>> wrote:
>> >>
>> >> It's not clear to me what you're trying to do.  An example would help.
>> >>
>> >> My guess is that you're looking for something like this:
>> >> x <- xts(1:10, Sys.Date()-10:1)
>> >> rbind(x, xts(NA_integer_,Sys.Date()-11))
>> >>
>> >> Best,
>> >> --
>> >> Joshua Ulrich  |  FOSS Trading: www.fosstrading.com
>> >>
>> >> R/Finance 2012: Applied Finance with R
>> >> www.RinFinance.com
>> >>
>> >>
>> >> On Mon, Apr 30, 2012 at 12:38 PM, Gordon Erlebacher
>> >> <gordon.erlebach@gmail.com> wrote:
>> >> > Hi,
>> >> >
>> >> > I have a xts object. Given a date, how do I get the index into the
>> >> > array?
>> >> > Is there a pre-written function?
>> >> >
>> >> > Thanks,
>> >> >
>> >> >  Gordon
>> >> >
>> >> >        [[alternative HTML version deleted]]
>> >> >
>> >> > _______________________________________________
>> >> > R-SIG-Finance@r-project.org mailing list
>> >> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> >> > -- Subscriber-posting only. If you want to post, subscribe first.
>> >> > -- Also note that this is not the r-help list where general R
>> questions
>> >> > should go.
>>
>
>

	[[alternative HTML version deleted]]

