D'oh -- won't work in general (weekends!) -- serves me right for being lazy on a Friday.
What your problem is that variables aren't extrapolated into strings, so you'll need to construct the subset string directly: dataspy[paste(startDate, endDate, sep="/")] or some such. (Untested!) Cheers, Michael On Fri, Nov 2, 2012 at 8:06 PM, R. Michael Weylandt <michael.weyla...@gmail.com> wrote: > head(dataspy, 6) seems easiest. > > Cheers, > Michael > > On Fri, Nov 2, 2012 at 6:41 PM, veepsirtt <veepsi...@gmail.com> wrote: >> Hi R, >> How to get the range of values form startDate to lastDate as given below?. >> >> #***************************************************************** >> # Load historical data >> #****************************************************************** >> library('quantmod') >> endDate =Sys.Date() >> startDate = as.Date(endDate-30, order="ymd") >> >> dataspy = getSymbols("SPY", from = startDate, to=endDate, auto.assign = >> FALSE) >> lastDate=startDate+5 >> >> #subset first 5 days >> dataspy['startDate::lastDate'] >> print(dataspy) >> >> Thanks >> veepsirtt >> >> >> >> >> -- >> View this message in context: >> http://r.789695.n4.nabble.com/Date-format-conversion-from-2012-09-20-to-2012-09-20-tp4643710p4648258.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. ______________________________________________ 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.