xts

Convert tab delimited to XTS within R?

二次信任 提交于 2019-12-11 05:19:56
问题 I have tab delimited file in format of: Date Time Last LastSize TotVol Bid Ask TickID BidSize AskSize 8/23/2012 0:00:00 0.95711 1 20670 0.95711 0.95742 0 0 0 8/23/2012 0:00:04 0.9571 1 20671 0.9571 0.9574 0 0 0 I am using the function to create an XTS within R. > EURUSD <- as.xts(read.zoo("C:\\Users\\caustic\\Documents\\DTN\\IQFeed\\EURUSD.FXCM_1.txt", + sep='\t', + tz='', + header=T, + format='%d/%m/%Y %H:%M:%S')) I get an error of: Error in as.POSIXlt.character(x, tz, ...) : character

R Rolling Random Forest for Variables Selection [closed]

爷,独闯天下 提交于 2019-12-11 04:45:31
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I've got a daily OHLC dataset of the Euro Stoxx 50 index since 2008 which looks like that : Open High Low Close Volume Adjusted 2008-01-02 4393.53 4411.59 4330.73 4339.23 0 4339.23 2008-01-03 4335.91 4344.36 4312

Plotting xts objects works with points but not with lines

跟風遠走 提交于 2019-12-11 04:34:59
问题 I have merged two xts objects and want to plot them in a single display. This works fine when I use points (type="p"). However, when I use lines (type="l") a problem occurs: the first series is shown only in the index region that is not covered by the second series. I would expect the lines to be as long as the "points". A reproducible example is posted below. As this occurs with both the default and the ggplot plotting commands, I suspect that this relates to some property of time-series

How to convert 10-minute time blocks to 1-minute intervals in R

。_饼干妹妹 提交于 2019-12-11 04:23:35
问题 I wish to convert 10-minute time blocks into 1-minute time blocks for a large vector. My datatime values are spaced at 10-minutes intervals, which represent a 10-minute time block ending at the given time stamp. Example data below: data<- structure(list(datetime = structure(1:7, .Label = c("30/11/2011 02:32", "30/11/2011 02:42", "30/11/2011 02:52", "30/11/2011 03:02", "30/11/2011 03:12", "30/11/2011 03:22", "30/11/2011 03:32"), class = "factor"), count = c(100L, 60L, 10L, 10L, 200L, 180L,

R: Aggregating time series data returns NA

眉间皱痕 提交于 2019-12-11 04:13:23
问题 I'm trying to aggreagate data by 5 minute means by using xts: library(xts) data <- read.csv("C:/Users/User/Documents/data.csv") times <- data$Time X <- as.POSIXct(times) X <- as.xts(X) DataTable <- period.apply(X, endpoints(X, "minutes", 5), mean) The problem is, if print out "DataTable", it shows that the aggregation didn't work, the aggregation scores are empty (NA). 2016-08-28 21:26:32 NA 2016-08-28 21:29:05 NA 2016-08-28 21:30:57 NA 2016-08-28 21:34:31 NA 2016-08-28 21:35:22 NA 2016-08-28

Timezone issue when filtering XTS using .indexhour

对着背影说爱祢 提交于 2019-12-11 02:59:06
问题 The following R code returns an unexpected output: times = c("2014-12-01 15:59:00", "2014-12-01 16:00:00", "2014-12-01 16:01:00") values = c(64.23, 64.43, 64.31) tim <- as.POSIXct(c("2014-12-01 15:59:00", "2014-12-01 16:00:00", "2014-12-01 16:01:00"), tz="GMT") myts <- xts(values, tim, tzone="GMT") print(myts[.indexhour(myts)==16]) I get: [,1] 2014-12-01 15:59:00 64.23 While I would expect: [,1] 2014-12-01 16:00:00 64.43 2014-12-01 16:01:00 64.31 I think .indexhour is somehow referring to my

Sorting xts data to look like panel data in R

安稳与你 提交于 2019-12-11 02:55:48
问题 I need to use 'PerformanceAnalytics' package of R and to use this package, it requires me to convert the data into xts data. The data can be downloaded from this link: https://drive.google.com/file/d/0B8usDJAPeV85elBmWXFwaXB4WUE/edit?usp=sharing . Hence, I have created an xts data by using the following commands: data<-read.csv('monthly.csv') dataxts <- xts(data[,-1],order.by=as.Date(data$datadate,format="%d/%m/%Y")) But after doing this, it looses the panel data structure. I tried to sort

Convert times series to.quarterly with NAs

。_饼干妹妹 提交于 2019-12-11 02:37:35
问题 I have a multivariate zoo time series that contains NAs and I want to convert that to a quarterly series. df1 <-1:12 df1[df1%%4==0] <- NA zoo.object <- zoo(matrix(df1, ncol=2),as.Date("2013-01-01")+(0:5)*35) colnames(zoo.object) <-c("stock1","stock2") > zoo.object stock1 stock2 2013-01-01 1 7 2013-02-05 2 NA 2013-03-12 3 9 2013-04-16 NA 10 2013-05-21 5 11 2013-06-25 6 NA Ideally, I would like to keep the earlier data in the quarter for each stocks. I have tried to.quarterly from the xts

How to plot xts in ggplot2?

試著忘記壹切 提交于 2019-12-11 01:45:50
问题 I got this plot using this code library(xts) library(zoo) plot.new() par(mai=c(2, 2, 1, 1)) plot(nats[,2], ylim=c(0, 2.5), xlab = "", ylab="", main="", major.ticks="months", major.format="%d-%b-%Y", minor.ticks=FALSE, las=1, cex.axis=0.8) points(nats[rans,2], col="darkgrey", pch=16, cex=0.5) points(M1[rans], col="red", pch=16, cex=0.5) points(M2[rans], col="blue", pch=16, cex=0.5) points(M3[rans], col="green", pch=16, cex=0.5) legend(x="topright", legend=c("a", "Actual value", "M1","M2","M3")

Changing time zone of XTS object

旧巷老猫 提交于 2019-12-11 01:37:30
问题 I have an data object with index(x) [6217] "2014-09-03 GMT" "2014-09-04 GMT" "2014-09-05 GMT" "2014-09-08 GMT" "2014-09-09 GMT" "2014-09-10 GMT" "2014-09-11 GMT" [6224] "2014-09-12 GMT" What can I do to change the objects time zone to "CDT"? Is there a function to do this? 回答1: With indexTZ<- indexTZ(x) <- "America/Chicago" 来源: https://stackoverflow.com/questions/25944277/changing-time-zone-of-xts-object