similar to: differecing a zoo series

Displaying 20 results from an estimated 2000 matches similar to: "differecing a zoo series"

2010 Dec 21
1
lm() on a matrix of zoo series
I have a matrix of zoo series. each series is in a column. x <- as.yearmon(2000 + seq(0, 23)/12) # 24 months of data, lets make 20 sets of random data testData <- matrix(rnorm(480),ncol=20) # make a zoo object and columns will hold the 20 series TestZoo <- zoo(testData,order.by=x) # now run lm for just one series. m <- lm(TestZoo[,1]~time(TestZoo))$coeff[2] m time(TestZoo)
2011 Sep 12
5
Hourly data with zoo
I have date data as a numeric and hourly data in 0 to 2300 hours in a dataframe. d <- rep(20110101,24) h <- seq(from = 0, to = 2300, by = 100) df <- data.frame(LST_DATE = d, LST_TIME = h, data = rnorm(24, 0, 1)) S <- chron(dates. = as.character(df$LST_DATE), times. = paste(as.character(df$LST_TIME/100), ":0:0", sep = ""), format =
2010 Aug 11
2
Sweeping a zoo series
Given a long zoo matrix, the goal is to "sweep" out a statistic from the entire length of the sequences. longzoomatrix<-zoo(matrix(rnorm(720),ncol=6),as.yearmon(outer(1900,seq(0,length=120)/12,"+"))) cnames<-c(12345,23456,34567,45678,56789,67890) colnames(longzoomatrix)<-cnames longzoomatrix[1:24,] 12345 23456 34567 45678
2010 Apr 25
3
Noobie question on aggregate tapply and by
I have a 43MB dataframe ( 5 variables) and I'm trying to summarize subsets of the data. I've RTFM ( not very clear) and looked at a variety of samples but cant seem to figure out how to make these functions work. A sample of what I want to do would be this: ids<-seq(1,50) years<-c(rep(5,10),rep(6,10),rep(7,10),rep(8,20))
2010 Jun 14
1
recursively Merging a list a zoo objects
The zoo package as a merge function which merges a set of zoo objects result<-merge(zoo1,zoo2,...) Assume your zoo objects are already collected in a list # make a phony list to illustrate the situation. ( hat tip to david W for constructing a list in a loop) ddat <- as.list(rep("", 20)) ytd<-seq(3,14) for(i in 1:20) { + ddat[[i]] <- zoo(data,ytd ) + } ddat [[1]] 1 2
2011 May 27
2
help with barplot
Hi, I'm really struggling with barplot I have a data.frame with 3 columns. The first column represents an "incident" type The second column represents a "month" The third column represents a "time" Code for a sample data.frame incidents <- rep(c('a','b','d','e'), each =25) months <- rep(c(1,2), each =10) times
2010 Jul 15
3
Summing over intervals
Given a matrix of MxN want to take the means of rows in the following fashion m<-matrix(seq(1,80),ncol=20, nrow=4) result<-matrix(NA,nrow=4,ncol=20/5) result[,1]<-apply(m[,1:5],1,mean) result[,2]<-apply(m[,6:10],1,mean) result[,3]<-apply(m[,11:15],1,mean) result[,4]<-apply(m[,16:20],1,mean) result [,1] [,2] [,3] [,4] [1,] 9 29 49 69 [2,] 10 30 50 70
2008 Mar 03
1
Formating a zoo dataset .
Suppose I have following dataset : > head(data1) Date Return 1 03/31/00 0.14230650 2 04/28/00 -0.03276228 3 05/31/00 -0.06527890 4 06/30/00 -0.04999873 5 07/31/00 -0.01447902 6 08/31/00 0.22265729 Now I convert it to zoo object : > data11 = zoo(data1[,2], as.Date(data1[,1], format="%m/%d/%y")) > head(data11) 2000-03-31 2000-04-28 2000-05-31
2010 Jun 05
5
Matrix to Vector
Given a matrix of m*n, I want to reorder it as a vector, using a row major transpose. so: > m<-matrix(seq(1,48),nrow=6,byrow=T) > m [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 1 2 3 4 5 6 7 8 [2,] 9 10 11 12 13 14 15 16 [3,] 17 18 19 20 21 22 23 24 [4,] 25 26 27 28 29 30 31 32 [5,] 33 34 35 36 37
2005 Apr 28
0
update: zoo 0.9-9
Dear useRs, a new version of the zoo package for totally ordered observations is available from CRAN. It contains many new features, the most important of which are: support of regular time series, an improved merge method and functions for carrying out rolling analyses of time series. A more detailed list of changes and new features is given below. All features (both old and new) are also
2005 Apr 28
0
update: zoo 0.9-9
Dear useRs, a new version of the zoo package for totally ordered observations is available from CRAN. It contains many new features, the most important of which are: support of regular time series, an improved merge method and functions for carrying out rolling analyses of time series. A more detailed list of changes and new features is given below. All features (both old and new) are also
2011 Jul 27
2
Elegant way to subtract matrix from array
there are really two related problems here I have a 2D matrix A <- matrix(1:100,nrow=20,ncol =5) S <- matrix(1:10,nrow=2,ncol =5) #I want to subtract S from A. so that S would be subtracted from the first 2 rows of #A, then the next two rows and so on. #I have a the same problem with a 3D array # where I want to subtract Q for every layer (1-10) in Z # I thought I solved this one
2011 Mar 18
2
Understanding tryCatch
I've read the help and the archives on tryCatch but I'm still stuggling trying to understand how it works exactly and how I can use it to get the result I need. I have a data.frame of urls which point to 11 .zip files. Basically I use RCurl to get the list of files from a ftp and then reduce that directory dump to the 11 zip files I want to download. Its easy enough to do that in a loop
2009 Jun 19
1
(FULL) Need help to optimize a piece of code involving zoo objects
(Sorry, sent the message before I finished it) Hello, everyone I have a long script that uses zoo objects. In this script I used simple moving averages and these I can very efficiently calculate with filter() functions. Now, I have to use special "exponential" moving averages, and the only way I could write the code was with a for-loop, which makes everything extremely slow. I don't
2009 Jun 19
1
Need help to optimize a piece of code involving zoo objects
Hello, everyone I have a long script that uses zoo objects. In this script I used simple moving averages and these I can very efficiently calculate with filter() functions. Now, I have to use special "exponential" moving averages, and the only way I could write the code was with a for-loop, which makes everything extremely slow. I don't know how to optimize the code, but I need to
2010 May 03
2
Adding a header after the file is written
The situation arises where I open a file to write a data.frame to it. with write.table. multiple lines are written to the file and the file is kept in Append=TRUE mode. If one sets the col.names to the names of the variables being written, you have output that looks like this... name1 name2 name3..... x x x x x x x x x name1 name2 name
2011 Sep 27
2
Coercing a character zoo to a numeric
Dear R-helpers, It seems to me that a character zoo cannot be coerced to a numeric zoo. Below is a minimal example. Can someone tell me what I have done wrong? > z<-zoo(1:4,order.by=1:4) > coredata(z)<-as.character(coredata(z)) > str(z) ‘zoo’ series from 1 to 4 Data: chr [1:4] "1" "2" "3" "4" Index: int [1:4] 1 2 3 4 >
2010 Aug 09
1
nested 'by'
Assuming a data frame or matrix with two columns representing variable that you want to aggregate over. you want to calculate column means, by year, for each Id example<-data.frame(id=c(rep(12345,5),rep(54321,6),rep(45678,7)),Year=rep(seq(1900,1902,by=1),6), x=seq(1,18,by=1),y=seq(18,1,by=-1)) example id Year x y 1 12345 1900 1 18 2 12345 1901 2 17 3 12345 1902 3 16 4 12345
2011 Nov 01
1
weird error
I was just rebuilding a package that has built before and I hit this error Error in loadNamespace(package, c(which.lib.loc, lib.loc), keep.source = keep.source) : cyclic name space dependency detected when loading 'GhcnDaily', already loading 'GhcnDaily' The package built just fine last revision, and the only changes I made were to Rd files How do I track this puppy down
2010 May 04
1
error in La.svd Lapack routine 'dgesdd'
Error in La.svd(x, nu, nv) : error code 1 from Lapack routine ‘dgesdd’ what resources are there to track down errors like this [[alternative HTML version deleted]]