zoo

Filling in missing (blanks) in a data table, per category - backwards and forwards

瘦欲@ 提交于 2019-12-17 07:26:21
问题 I am working with a large data set of billing records for my clinical practice over 11 years . Quite a few of the rows are missing the referring physician. However, using some rules I can quite easily fill them in but do not know how to implement it in data.table under R. I know that there are things such as na.locf in the zoo package and self rolling join in the data.table package. The examples that I have seen are too simplistic and do not help me. Here is some fictitious data to orient you

optimized rolling functions on irregular time series with time-based window

*爱你&永不变心* 提交于 2019-12-17 07:24:02
问题 Is there some way to use rollapply (from zoo package or something similar) optimized functions ( rollmean , rollmedian etc) to compute rolling functions with a time-based window, instead of one based on a number of observations? What I want is simple: for each element in an irregular time series, I want to compute a rolling function with a N-days window. That is, the window should include all the observations up to N days before the current observation. Time series may also contain duplicates

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

ZooKeeper系列(三)

僤鯓⒐⒋嵵緔 提交于 2019-12-17 05:15:17
前面虽然配置了集群模式的Zookeeper,但是为了方面学建议在伪分布式模式的Zookeeper学习Zookeeper的shell命令。 一、Zookeeper的四字命令 Zookeeper支持某些特定的四字命令字母与其的交互。他们大多数是查询命令,用来获取Zookeeper服务的当前状态及相关信息。用户在客户端可以通过telnet或nc向Zookeeper提交相应的命令。Zookeeper常用的四字命令见图1.1所示。 图 1.1 图1.2是Zookeeper四字命令的一个简单用例。 [root@hadoop ~]# echo ruok|nc localhost 2181 [root@hadoop ~]# zkServer.sh start zoo1.cfg JMX enabled by default Using config: /usr/local/zk/bin/../conf/zoo1.cfg Starting zookeeper ... STARTED [root@hadoop ~]# zkServer.sh start zoo2.cfg JMX enabled by default Using config: /usr/local/zk/bin/../conf/zoo2.cfg Starting zookeeper ... STARTED [root@hadoop ~]

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]

Sorting a zoo object by value

你。 提交于 2019-12-13 21:01:04
问题 I have a zoo time series object. How do I sort it by value, while preserving the dates? If this is my series: 2013-10-02 2013-10-03 2013-10-04 2013-10-07 2013-10-08 2013-10-09 -0.02 0.00 0.00 0.04 0.00 0.02 The result should be: 2013-10-02 2013-10-03 2013-10-04 2013-10-08 2013-10-09 2013-10-07 -0.02 0 0 0 0.02 0.04 Ordinary sort sorts the zoo object by date (not value). zoo object (date, 1 value series) has dim NULL, so it's not possible to specify that I want to sort by the second column.

R/zoo: handle non-unique index entries but not lose data?

情到浓时终转凉″ 提交于 2019-12-13 18:09:28
问题 I've a csv file of data points (e.g. financial ticks, experiment recordings, etc.), and my data has duplicate timestamps. Here is code demonstrating the problem: library(zoo);library(xts) csv="2011-11-01,50 2011-11-02,49 2011-11-02,48 2011-11-03,47 2011-11-03,46 2011-11-03,45 2011-11-04,44 2011-11-04,43 2011-11-04,42 2011-11-04,41 " z1=read.zoo(textConnection(csv),sep=',') w1=to.weekly(z1) ep=endpoints(z1,"weeks",1) w1$Volume=period.apply(z1,ep,length) z2=read.zoo(textConnection(csv),sep=','

Using rollapply and lm over multiple columns of data

非 Y 不嫁゛ 提交于 2019-12-13 15:26:34
问题 I have a data frame similar to the following with a total of 500 columns: Probes <- data.frame(Days=seq(0.01, 4.91, 0.01), B1=5:495,B2=-100:390, B3=10:500,B4=-200:290) I would like to calculate a rolling window linear regression where my window size is 12 data points and each sequential regression is separated by 6 data points. For each regression, "Days" will always be the x component of the model, and the y's would be each of the other columns (B1, followed by B2, B3, etc). I would then

Rolling regression return multiple objects

筅森魡賤 提交于 2019-12-13 12:23:11
问题 I am trying to build a rolling regression function based on the example here, but in addition to returning the predicted values, I would like to return the some rolling model diagnostics (i.e. coefficients, t-values, and mabye R^2). I would like the results to be returned in discrete objects based on the type of results. The example provided in the link above sucessfully creates thr rolling predictions, but I need some assistance packaging and writing out the rolling model diagnostics: In the