xts

Fill NA in a time series only to a limited number

不打扰是莪最后的温柔 提交于 2019-12-17 09:48:11
问题 Is there a way we can fill NA s in a zoo or xts object with limited number of NA s forward. In other words like fill NA s up to 3 consecutive NA s, and then keep the NA s from the 4th value on until a valid number. Something like this. library(zoo) x <- zoo(1:20, Sys.Date() + 1:20) x[c(2:4, 6:10, 13:18)] <- NA x 2014-09-20 2014-09-21 2014-09-22 2014-09-23 2014-09-24 2014-09-25 2014-09-26 1 NA NA NA 5 NA NA 2014-09-27 2014-09-28 2014-09-29 2014-09-30 2014-10-01 2014-10-02 2014-10-03 NA NA NA

Creating regular 15-minute time-series from irregular time-series

血红的双手。 提交于 2019-12-17 07:15:35
问题 I have an irregular time-series (with DateTime and RainfallValue) in a csv file C:\SampleData.csv : DateTime,RainInches 1/6/2000 11:59,0 1/6/2000 23:59,0.01 1/7/2000 11:59,0 1/13/2000 23:59,0 1/14/2000 0:00,0 1/14/2000 23:59,0 4/14/2000 3:07,0.01 4/14/2000 3:12,0.03 4/14/2000 3:19,0.01 12/31/2001 22:44,0 12/31/2001 22:59,0.07 12/31/2001 23:14,0 12/31/2001 23:29,0 12/31/2001 23:44,0.01 12/31/2001 23:59,0.01 Note: The irregular time-steps could be 1 min, 15 min, 1 hour, etc. Also, there could

Creating regular 15-minute time-series from irregular time-series

梦想与她 提交于 2019-12-17 07:15:01
问题 I have an irregular time-series (with DateTime and RainfallValue) in a csv file C:\SampleData.csv : DateTime,RainInches 1/6/2000 11:59,0 1/6/2000 23:59,0.01 1/7/2000 11:59,0 1/13/2000 23:59,0 1/14/2000 0:00,0 1/14/2000 23:59,0 4/14/2000 3:07,0.01 4/14/2000 3:12,0.03 4/14/2000 3:19,0.01 12/31/2001 22:44,0 12/31/2001 22:59,0.07 12/31/2001 23:14,0 12/31/2001 23:29,0 12/31/2001 23:44,0.01 12/31/2001 23:59,0.01 Note: The irregular time-steps could be 1 min, 15 min, 1 hour, etc. Also, there could

Which is the best method to apply a script repetitively to n .csv files in R?

独自空忆成欢 提交于 2019-12-17 06:47:27
问题 My situation : I have a number of csv files all with the same suffix pre .csv, but the first two characters of the file name are different (ie AA01.csv, AB01.csv, AC01.csv etc) I have an R script which I would like to run on each file. This file essentially extracts the data from the .csv and assigns them to vectors / converts them into timeseries objects. (For example, AA01 xts timeseries object, AB01 xts object) What I would like to achieve : Embed the script within a larger loop (or as

Which is the best method to apply a script repetitively to n .csv files in R?

烂漫一生 提交于 2019-12-17 06:47:06
问题 My situation : I have a number of csv files all with the same suffix pre .csv, but the first two characters of the file name are different (ie AA01.csv, AB01.csv, AC01.csv etc) I have an R script which I would like to run on each file. This file essentially extracts the data from the .csv and assigns them to vectors / converts them into timeseries objects. (For example, AA01 xts timeseries object, AB01 xts object) What I would like to achieve : Embed the script within a larger loop (or as

Which is the best method to apply a script repetitively to n .csv files in R?

岁酱吖の 提交于 2019-12-17 06:47:06
问题 My situation : I have a number of csv files all with the same suffix pre .csv, but the first two characters of the file name are different (ie AA01.csv, AB01.csv, AC01.csv etc) I have an R script which I would like to run on each file. This file essentially extracts the data from the .csv and assigns them to vectors / converts them into timeseries objects. (For example, AA01 xts timeseries object, AB01 xts object) What I would like to achieve : Embed the script within a larger loop (or as

XTS to.weekly returns different weekly endpoints

喜你入骨 提交于 2019-12-14 04:18:57
问题 I have a problem where the endpoints() function in xts (and also the to.weekly function, which uses endpoints) sometimes returns Friday as the end of week, and sometimes returns Monday. My dataset is called sp2 . > head(sp2) [,1] 2012-01-09 1.78 2012-01-10 1.78 2012-01-11 1.77 2012-01-12 1.80 2012-01-13 1.77 2012-01-16 1.77 > tail(sp2) [,1] 2012-06-28 1.94 2012-06-29 1.92 2012-07-02 1.92 2012-07-03 1.90 2012-07-04 1.89 2012-07-05 1.89 > class(sp2) [1] "xts" "zoo" > weekdays(index(sp2)) [1]

R: using stl() on an xts object

丶灬走出姿态 提交于 2019-12-14 02:32:49
问题 I'm relatively new to R so please bear with me. I'm trying to get to grips with basic irregular time-series analysis. That's what my data file looks like, some 40k lines. The spacing is not always exactly 20sec. Time, Avg 04/03/2015 00:00:23,20.24 04/03/2015 00:00:43,20.38 04/03/2015 00:01:03,20.53 04/03/2015 00:01:23,20.54 04/03/2015 00:01:43,20.53 data <- read.zoo("data.csv",sep=",",tz='',header=T,format='%d/%m/%Y %H:%M:%S') I'm happy to aggregate by minutes data <- to.minutes(as.xts(data))

Change plot area background color

你。 提交于 2019-12-13 15:11:03
问题 I would like to do a graph in R using our company colors. This means the background of all charts should be a light blue, the plotting region however should be white. I was searching for answers and found that drawing a rect does the job (almost). However the plotting region is now white and the graph not visible anymore. Is this even possible? getSymbols('SPY', from='1998-01-01', to='2011-07-31', adjust=T) GRAPH_BLUE<-rgb(43/255, 71/255,153/255) GRAPH_ORANGE<-rgb(243/255, 112/255, 33/255)

installing the package xtsExtra on a windows machine

安稳与你 提交于 2019-12-13 13:11:53
问题 I am having a bit of difficulty installing the R package xtsExtra on a windows machine..., and not too sure whats wrong... > install.packages("xtsExtra", ,repos="http://R-Forge.R-project.org") Warning in install.packages : package ‘xtsExtra’ is not available (for R version 3.0.0) Error in install.packages : argument is missing, with no default > sessionInfo() R version 3.0.0 (2013-04-03) Platform: i386-w64-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE