similar to: How to calculate mean of every nth time series data with zoo or xts ?

Displaying 20 results from an estimated 5000 matches similar to: "How to calculate mean of every nth time series data with zoo or xts ?"

2012 Jul 29
1
readRDS, In as.double.xts(fishReport$count) : NAs introduced by coercion
Hello, I looked in the R-help but could not find an archive addressing the following. I would like to convert a character to numeric after reading a file with RDS extension. After using as.numeric, I checked if it is numeric. It was not converted. Please help. Here is my code >Report <- readRDS(file="RDS/Report.RDS") > Report[1:2,] dive_id date
2010 Nov 05
1
as.xts
hey I am trying to turn a dataframe into xts with the function: as.xts, but it returns the error: Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format could someone give me some pointers please the data is coming from a spreadsheet via the excel, and has 5 columns of data (date (with the date and time), open, high, low, close) (excel format) ela
2011 Oct 21
2
plotting with a symbol on every nth point
Hi, I would like to produce a plot with a symbol on every nth point in a time series data, like the one in the following: http://www.phon.ucl.ac.uk/home/yi/ProsodyPro/EnglishFocus.png x <- seq(-100,1000,25) plot(x,type="l") Could someone help me out with the above example? Thanks.... [[alternative HTML version deleted]]
2005 Oct 25
1
selecting every nth item in the data
I want to make a glm and then use predict. I have a fairly small sample (4000 cases) and I want to train on 90% and test on 10% but I want to do it in slices so I test on every 10th case and train on the others. Is there some simple way to get these elements? Stephen -- 21/10/2005 [[alternative HTML version deleted]]
2012 Apr 05
3
Apply function to every 'nth' element of a vector
Dear R users, how do I e.g. square each second element of a vector with an even number of elements? Or more generally to apply a function to every 'nth' element of a vector. I looked into the apply functions, but found no hint. For example: v <- c(1, 2, 3, 4) mysquare <- function (x) { return (x*x) } w <- applyfun(v, mysquare, 2) then w should be c(1, 4, 3, 16) Thanks for
2008 Feb 25
1
Plotting series marked with a symbol on every nth data point, preferably in ggplot...
Hello! I am working with signals and a plot of several signals on the same axes can get quite messy. With lines that are very fractured, distinction by only the linestyle is not very clear. If I add symbols to the plot however, there are so many symbols, that they overplot and the whole plot is unreadable once again. I am looking for advice on how to make a plot with continuous lines and symbols
2001 Mar 28
4
How to extract every nth element from a vector
R-helpers: Is there a simple way to extract every nth element from a very long vector? [The vector I want to sample from is an object returned by lowess(). It is so long (11,628 pairs of elements) that it is causing non-R-related memory problems elsewhere. I don't see a better way other than sampling the output returned from lowess.] Thanks in advance. Barry Cooke
2010 May 17
1
Isn't aggreate.zoo supposed to work with POSIXct (zoo/TTR/xts issue)?
library(xts) library(TTR) ndx = getYahooData("^NDX") aa = ndx$Close bb = aggregate(aa, as.yearweek, tail, 1) The last operation takes forever, and then the bb dates are messed up. The following produces the desired result: time(aa) = as.Date(time(aa)) bb = aggregate(aa, as.yearweek, tail, 1) The index of ndx and aa is of POSIXct (as reported by is(time(ndx))) , which apparently
2011 Mar 02
1
Create a zoo/xts Time Series with Millisecond jumps
Is there a easy way to create the time index for a zoo/xts object for every 100 milliseconds. eg. time Index would be: 10:00:00:100 10:00:00:200 10:00:00:300 10:00:00:400 I am looking to build an empty zoo/xts object with time index from 10am to 3pm, index jumps by 100ms each row. Thanks, Chris -- View this message in context:
2009 Sep 25
0
differing behaviour between xts (0.6-7) and zoo (1.5-8)
Folks, I have some weekly dataseries that I convert to monthly xts (with yearmon indices), and obtain the two following extracts: > str(sig) An 'xts' object from Apr 1998 to Sep 1998 containing: Data: num [1:6, 1] 0.0083 0.2799 -0.2524 -0.0119 0.18 ... - attr(*, "dimnames")=List of 2 ..$ : NULL ..$ : chr "e1" Indexed by objects of class: [yearmon] TZ:
2017 Oct 06
2
Time series: xts/zoo object at annual (yearly) frequency
Hi, I'd like to make a time series at an annual frequency. > a<-xts(x=c(2,4,5), order.by=c("1991","1992","1993")) Error in xts(x = c(2, 4, 5), order.by = c("1991", "1992", "1993")) : order.by requires an appropriate time-based object > a<-xts(x=c(2,4,5), order.by=1991:1993) Error in xts(x = c(2, 4, 5), order.by =
2010 Jan 14
0
chron, xts and zoo
dear r folks i am a bit puzzled about how to use chron as an index xts and why it differs from zoo. in this example, why can i index zoo but not xts x<-1:23 time.of.day <- times(paste(x,":0:0",sep=""),format="h:m:s") day <- dates("4/8/90") period <- chron(dates=day,times=time.of.day) xts(1:23,period) zoo(1:23,period) i suspect it might be to
2011 May 28
1
How to do operations on zoo/xts objects with Monthly and Daily periodicities
Is there an elegant way to do operations (+/-/*/ / ) on zoo/xts objects when one serie is monthly (end of month) and the other daily (weekdays only) - typically a monthly economic indicator and a stock index price? Thanks, TDB -- View this message in context: http://r.789695.n4.nabble.com/How-to-do-operations-on-zoo-xts-objects-with-Monthly-and-Daily-periodicities-tp3558081p3558081.html
2011 Jan 23
1
Plotting multiple xts/zoo time series on a single plot.
So I've got a 154 column wide xts time series object and I want to plot the 154 series on a single plot and have the added benefit of the time series dates on the x axis. Any suggestions for plotting functions, maplot works but does not give dates on the axis and I can't seem to get plot to give me more than one series. Nick [[alternative HTML version deleted]]
2012 Nov 27
2
Books for fully understanding internal logics on some packages(quantmod, xts, zoo and chron)
Hello, I'm very interested in using financial time series data, but I'm a beginner of R programming. I'd like to fully understand internal logics on several time-series related packages such as quantmod, xts, zoo, chron, etc. So, I read some books, 'R Cookbook' and 'Art of R Programming' and another simple tutorials. But I still can't understand grammars of the
2012 Apr 23
2
subset daily to monthly in a zoo or xts
Dear R users, I want to subset a daily zoo series according to its month, find % of "NA" in each month. I am finding it difficult to subset the daily dataset into monthly for the given operation.I am planning to do this for a huge dataset. Thanks in advance. Regards Vikram [[alternative HTML version deleted]]
2010 Apr 20
1
converting a zoo or an xts to a data frame
Dear R People: I have the following code that I use to convert a monthly zoo object to a data.frame, and it works perfectly: library(tseries) z <- get.hist.quote(instrument=inst1, start=start1,end=end1, quote=quot1,comp = "m") y <- as.ts(aggregate(z, as.yearmon, tail, 1)) y.df <- data.frame(y=y,time=time(y)) y.df$x <- ts(y.df[,1]) tsp(y.df$x) <-
2011 Apr 03
1
zoo:rollapply by multiple grouping factors
# Hi there, # I am trying to apply a function over a moving-window for a large number of multivariate time-series that are grouped in a nested set of factors. I have spent a few days searching for solutions with no luck, so any suggestions are much appreciated. # The data I have are for the abundance dynamics of multiple species observed in multiple fixed plots at multiple sites. (I total I
2010 Apr 18
4
confused with yearmon, xts and maybe zoo
R-listers, I am using xts with a yearmon index, but am getting some inconsistent results with the date index when i drop observations (for example by using na.omit). The issue is illustrated in the example below. If I start with a monthly zooreg series starting in 2009, yearmon converts this to "Dec-2008". Not such a worry for my example, but strange. Having converted to xts, i drop
2013 Jan 04
2
Can you help me please
HI Fares, You could try this: dat1<- read.table(text=" date????? donation 3jan2003?? 20235 4jan2003?? 25655 5jan2003?? 225860 6jan2003?? 289658 7jan2003?? 243889 8jan2003?? 244338 9jan2003?? 243889 ",sep="",header=TRUE,stringsAsFactors=FALSE) The post is not very specific as to what you need.? I hope this works for you. library(xts)