[R] try to subset zoo dataset
arun
smartpink111 at yahoo.com
Sat Oct 5 05:21:13 CEST 2013
Hi,
Try:
library(zoo)
z2<- read.zoo(text="Date WBK_Last WBK_1d_Close
2003-01-03 13.88506 14.08276
2003-01-06 14.11254 13.88506
2003-01-07 14.07033 14.11254
2003-01-14 14.24165 14.30967
2003-01-22 14.28913 14.30563
2003-01-29 13.95664 14.16483
2007-01-01 14.87033 15.11254
2007-01-07 14.34165 14.50967
2007-01-22 12.24913 14.80563
2008-01-29 12.95664 14.26483",sep="",header=TRUE,FUN=as.Date,format="%Y-%m-%d")
library(xts)
x1<- as.xts(z2)
x1["2007-01-01/2007-12-31"]
# WBK_Last WBK_1d_Close
#2007-01-01 14.87033 15.11254
#2007-01-07 14.34165 14.50967
#2007-01-22 12.24913 14.80563
x1["2007-01-01/"]
# WBK_Last WBK_1d_Close
#2007-01-01 14.87033 15.11254
#2007-01-07 14.34165 14.50967
#2007-01-22 12.24913 14.80563
#2008-01-29 12.95664 14.26483
A.K.
Hi There,
I have a zoo dataset with more 10-year daily price data. However, I only want data from a specific date onward.
This is how my data looks like:
WBK_Last WBK_1d_Close
2003-01-03 13.88506 14.08276
2003-01-06 14.11254 13.88506
2003-01-07 14.07033 14.11254
2003-01-14 14.24165 14.30967
2003-01-22 14.28913 14.30563
2003-01-29 13.95664 14.16483
However, I only want data from 2007-01-01 onward.
I know I can use " prices[as.Date"2007-01-01"] " to find out the
data of the starting date but I can't subset the dataset from that date.
Thank you in advance.
Any help will be appreciated.
More information about the R-help
mailing list