Questions tagged [zoo]

zoo is an R package that provides an S3 class with methods for totally ordered indexed observations.

zoo ("Z's Ordered Observations") is an package for analysis of regular and irregular time series.

It provides an class with methods for totally ordered indexed observations. It is particularly aimed at irregular of numeric vectors/matrices and factors. zoo's key design goals are independence of a particular index/date/time class and consistency with ts in base-R by providing methods to extend standard generics.

Repositories

Vignettes

Other resources

Related tags

1328 questions
0
votes
1 answer

as.yearmon in zoo not working correctly

I have a script on my desktop that works fine, but I had to migrate to Windows Server 2012 for work and now I'm getting a weird bug. I'm trying to convert a mon-yr date format string to a zoo date using the as.yearmon() zoo function. This works fine…
Dirk Calloway
  • 2,569
  • 4
  • 23
  • 34
0
votes
2 answers

R get only positive/negative delta using diff

I have a time series data that has been imported as zoo class. and my data looks like this: # you can recreate my problem using the code below library(rjson) library(plyr) library(zoo) value <- '[["2013-08-08", 7944, 0.37], ["2013-08-09", 7924,…
B.Mr.W.
  • 18,910
  • 35
  • 114
  • 178
0
votes
1 answer

r merge zoo objects in for loop error

I get an error attempting to merge two zoo objects. They have the same index. here is the partial code that isolates the error: DFE[[i]]<-setNames(merge(DEMHR[,i],ADHR[,i]), c(dimnames(DEMHR)[[2]][i],dimnames(ADHR)[[2]][i])) Below is the error I…
Reginald Roberts
  • 123
  • 3
  • 10
0
votes
1 answer

R - PerformanceAnalytics - SharpRatio rollapply zoo

I have been trying to work with the SharpeRatio function in the PerformanceAnalytics package. I am trying to rollapply the Sharpe Ratio over a zoo object but a think the results are not ok. Can anyone say why I cannot apply this like…
husvar
  • 373
  • 1
  • 3
  • 13
0
votes
0 answers

Creating next Data.Frame by pulling columns from previous sequenced Data.Frame in a for Loop

My goal: is to write a loop that creates a unique data.frame for a multivariate time series that is split by a factor called hour. The data is daily and has values for demand and ad spend at each hour of the day. Each data.frame has1 date column,…
Eric Blake
  • 37
  • 6
0
votes
2 answers

rbind.zoo doesn't seem create consistent zoo object

I want to rbind.zoo two zoo object together. When I was testing I came across the following issue(?)... Note: The below is an example, there is clearly no point to it apart from being illustrative. I have an zoo object, call it, 'X'. I want to…
olaf
  • 127
  • 1
  • 1
  • 6
0
votes
0 answers

Deseasonalize a "zoo" object containing intraday data

Using the zoo package (and help from SO) I have created a time series from the following: z <- read.zoo("D:\\Futures Data\\BNVol3.csv", sep = ",", header = TRUE, index = 1:2, tz="", format = "%d/%m/%Y %H:%M") This holds data in the following…
azuric
  • 2,679
  • 7
  • 29
  • 44
0
votes
1 answer

How can I use zoo::rollapply to create a `rollscale` implementation?

I would like to implement the following rollscale function that scales (centers and normalizes i.e. subtract mu and divide by sigma) the dataset x but instead of doing it using a global mu and sigma they are computed within a rolling window on the…
SkyWalker
  • 13,729
  • 18
  • 91
  • 187
0
votes
1 answer

R data.table merge / full outer join with na.fill / nomatch based on formula

What I need is to perform full outer join with some kind of smart na.fill / nomatch in a efficient way. I've already done it using loop but I would like to use matrix algebra or data.table operations to speed up the process. Data below are sample of…
jangorecki
  • 16,384
  • 4
  • 79
  • 160
0
votes
1 answer

Use a zoo's values as column lookups in another zoo

I'm trying create a lookup of sorts, to get a data structure (ideally a zoo) that uses the values in one zoo (myZoo2 below) as column names to look up the values in another (myZoo). A simple example: require('zoo') require('tseries') dates =…
StatsViaCsh
  • 2,600
  • 10
  • 44
  • 63
0
votes
1 answer

Extract set of rows that rollapply evaluates to TRUE?

Say I have a data frame df <- data.frame(A=c(1,3,1,4,2,2,5,3,1,7,8),b=c(10:20),c=c(20:30)) and I want to extract all the consecutive rows whose sum in column A is 4. I can run through with rollapply from package zoo and easily find out if there are…
yawgeh
  • 97
  • 1
  • 10
0
votes
1 answer

merging aggregate data in R (again)

Following up my earlier question with the same title, I have a long term sub-hourly data, and I want to aggregate the data in various ways. I want to have the aggregate based on the hour of the day, but also on the combinations of aggregation, for…
ery
  • 992
  • 3
  • 14
  • 25
0
votes
1 answer

How do I calculate a percent change of a zoo object using sapply?

I have a list of zoo objects. The core data is the adjusted close of several stock symbols, monthly data. Each list object is a separate time series for each ticker. I'd like to calculate the monthly change for each month, in each object. If it…
StatsViaCsh
  • 2,600
  • 10
  • 44
  • 63
0
votes
1 answer

Plot multiple moving average on multiple data-set in one graph

I have a data frame which consists from 3 columns: time, A, B. I managed to plot (A and B) VS time in one graph. I'd like to calculate the moving average for A, B and plot it on the same graph. I found similar question, however, it's for single…
SimpleNEasy
  • 879
  • 3
  • 11
  • 32
0
votes
1 answer

How to thin out data in zoo

Is there a function that let me thin out my data (time-series as zoo)? The Example would be mytime<-as.POSIXct(paste("2013-07-09 12:", c(1:59), sep="")) mydata<-EuStockMarkets[1:59] myts<-zoo(mydata, mytime) I search a function that returns an…