[R-SIG-Finance] Removing a row in an xts object in place?
Jeffrey Ryan
jeffrey.ryan at lemnica.com
Mon Jan 23 20:24:44 CET 2012
On Sat, Jan 21, 2012 at 8:03 PM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
> Short answer: I'm pretty sure it's impossible to remove elements "in place".
Not impossible, just not likely ;-)
>
> 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....
The indexing/mmap package (by me) is an aim at this. data.table,
while a stellar replacement for an in-memory db (and data.frames),
isn't going to save you anything here. What you need to do is keep
things _out of core_, search on disk and then pull in what you need.
(this is what indexing project does).
>
> 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.
The only thing that could be done here differently in the belly of xts
would be to assign back to the object that is passed in. I think
"eek" is how some of R-core would respond to that proposal. Of
course, that doesn't mean it isn't done in some 'non-published' code
from time to time ;-)
Jeff
>
> 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.
>
> _______________________________________________
> 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.
--
Jeffrey Ryan
jeffrey.ryan at lemnica.com
www.lemnica.com
www.esotericR.com
More information about the R-SIG-Finance
mailing list