[R-SIG-Finance] Removing a row in an xts object in place?

R. Michael Weylandt michael.weylandt at gmail.com
Sun Jan 22 03:03:48 CET 2012


Short answer: I'm pretty sure it's impossible to remove elements "in place".

Medium answer: If you are worried about memory usage, I might suggest
using the data.table() package. It's pretty efficient for most things,
though you'll loose xts specific time-functionality. You might be able
to wedge time stamps in though smart use of the keys. (I'm not
familiar enough with the package to say for sure.) Pondering aloud,
merging data.table and xts functionalities sounds like an
exceptionally fun project and a new package idea. I might do that when
life gets 80% less busy....

Long answer: it *may* be possible using the .Call() interface and
playing very deeply with the internals (I haven't looked at them
recently enough to say one way or the other) but it's exceptionally
dangerous since R uses copy-on-change semantics. If you are determined
enough, I think I can see a way that it's doable, but it's such a
non-R thing to do that I don't think you'll get much help.

Michael

On Sat, Jan 21, 2012 at 7:13 PM, Michael <comtech.usa at gmail.com> wrote:
> I hope I can do:
>
> x[ !Conditions, ] = NULL
>
> or something like this...
>
> On Sat, Jan 21, 2012 at 6:13 PM, Michael <comtech.usa at gmail.com> wrote:
>
>> Hi all,
>>
>> How do I remove a row in an xts object and the operation has to be in
>> place?
>>
>> I knew I can do
>>
>> y=x[ Conditions, ]
>>
>> where x is the original time series xts object...
>>
>> But if x and y both are huge,
>>
>> this operation can consume a lot of memory...
>>
>> Any thoughts?
>>
>> Thanks a lot!
>>
>>
>>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at 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.



More information about the R-SIG-Finance mailing list