Hi,

I have a very large XTS object.  It is about 600,000 entries over 1 year time.

I would like to subset a specific piece, by "number of days" not a specific 
date.

The way I do it now is awkward.  Would love to find a way to do this easier to 
generate a new object just containing the days I want.

---------------------------------------
dayEnds <- endpoints(dataset, on="days")
datasetEnd <- max(dayEnds)
for( d in 1:ndays(dataset)){
        day <- dataset[ (dayEnds[d]+1):dayEnds[d+1], ]
        
        daysToEnd <- round(as.numeric( index(dataset[datasetEnd]) - 
index(tail(day, n=1)) , unit="days"  ))
        if(daysToEnd > 30|| daysToEnd < 10){
                next;
        }
        
        # Will only get here if the days until the end are between 10 and 30
        #  Do the work here
}
-------------------------------------------


The above works but:
        1) It is slow and awkward
        2) I never wind up with a single clean dataset of just the days I want. 
 

Any ideas?

Thanks!

--
Noah Silverman
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to