On Tue, Oct 16, 2012 at 5:04 AM, john.dempster78 <john.dempste...@gmail.com> wrote: > Hi, > How can an xts object be subset using a date in a variable? > E.g. in below, what is the right syntax for Q to get the same value as P? > Obviously the syntax shown below doesnt work... > V is an xts object. > > R
> P <- V['2007-01-01/'] > Q <- V['d/'] > To clarify, d is a character string, not a Date. In order for Q to be like P, you need to create a character string from d that equals the one you used to create P. You can do this with paste(). Q <- V[paste(d,"/",sep="")] > Thanks, > J > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/XTS-Subsetting-question-noob-tp4646317.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.