|
> colnames = c("date","price")
> data = read.csv(file="data.csv", sep=",", header=F, nrows=261, skip=5, col.names=colnames) > library(quantmod) > data date price 1 2011-12-18 13.7825 2 2011-12-11 13.5500 ... ... ... 259 2007-01-07 10.8256 260 2006-12-31 10.8531 261 2006-12-24 10.8169 # Here's where I would like to use chartSeries from quantmod, but I'm stumped, so I try several different things > chartSeries(date, price, data=data) Error in try.xts(x, error = "chartSeries requires an xtsible object") : chartSeries requires an xtsible object > ?chartSeries > chartSeries(date, price, type="candlesticks", theme = chartTheme("black")) Error in try.xts(x, error = "chartSeries requires an xtsible object") : chartSeries requires an xtsible object > chartSeries(date, price, type="candlesticks", theme = chartTheme("black"), subset='2007::2008-01') Error in try.xts(x, error = "chartSeries requires an xtsible object") : chartSeries requires an xtsible object Help is appreciated very much! ______________________________________________ [hidden email] 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. |
|
Thanks to mrflick on Freenode, I was able to get chartSeries to plot the data.
data$date<-strptime(data$date, format="%Y-%m-%d") dataxts<-xts(data$price, order.by=data$date) chartSeries(dataxts) chartSeries(dataxts, type="candlesticks") plots the same graph though: http://i.imgur.com/P0Jh0.png Why is this? On Wed, Dec 21, 2011 at 9:10 PM, Adrian Berg <[hidden email]> wrote: >> colnames = c("date","price") >> data = read.csv(file="data.csv", sep=",", header=F, nrows=261, skip=5, col.names=colnames) >> library(quantmod) >> data > date price > 1 2011-12-18 13.7825 > 2 2011-12-11 13.5500 > ... > ... > ... > 259 2007-01-07 10.8256 > 260 2006-12-31 10.8531 > 261 2006-12-24 10.8169 > > # Here's where I would like to use chartSeries from quantmod, but I'm > stumped, so I try several different things > >> chartSeries(date, price, data=data) > Error in try.xts(x, error = "chartSeries requires an xtsible object") : > chartSeries requires an xtsible object >> ?chartSeries >> chartSeries(date, price, type="candlesticks", theme = chartTheme("black")) > Error in try.xts(x, error = "chartSeries requires an xtsible object") : > chartSeries requires an xtsible object >> chartSeries(date, price, type="candlesticks", theme = chartTheme("black"), subset='2007::2008-01') > Error in try.xts(x, error = "chartSeries requires an xtsible object") : > chartSeries requires an xtsible object > > > Help is appreciated very much! ______________________________________________ [hidden email] 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. |
|
Both
> barChart(dataxts,bar.type='hlc') > candleChart(dataxts) give the same results as well. On Wed, Dec 21, 2011 at 11:15 PM, Adrian Berg <[hidden email]> wrote: > Thanks to mrflick on Freenode, I was able to get chartSeries to plot the data. > > data$date<-strptime(data$date, format="%Y-%m-%d") > dataxts<-xts(data$price, order.by=data$date) > chartSeries(dataxts) > > chartSeries(dataxts, type="candlesticks") plots the same graph though: > http://i.imgur.com/P0Jh0.png > > Why is this? > > On Wed, Dec 21, 2011 at 9:10 PM, Adrian Berg <[hidden email]> wrote: >>> colnames = c("date","price") >>> data = read.csv(file="data.csv", sep=",", header=F, nrows=261, skip=5, col.names=colnames) >>> library(quantmod) >>> data >> date price >> 1 2011-12-18 13.7825 >> 2 2011-12-11 13.5500 >> ... >> ... >> ... >> 259 2007-01-07 10.8256 >> 260 2006-12-31 10.8531 >> 261 2006-12-24 10.8169 >> >> # Here's where I would like to use chartSeries from quantmod, but I'm >> stumped, so I try several different things >> >>> chartSeries(date, price, data=data) >> Error in try.xts(x, error = "chartSeries requires an xtsible object") : >> chartSeries requires an xtsible object >>> ?chartSeries >>> chartSeries(date, price, type="candlesticks", theme = chartTheme("black")) >> Error in try.xts(x, error = "chartSeries requires an xtsible object") : >> chartSeries requires an xtsible object >>> chartSeries(date, price, type="candlesticks", theme = chartTheme("black"), subset='2007::2008-01') >> Error in try.xts(x, error = "chartSeries requires an xtsible object") : >> chartSeries requires an xtsible object >> >> >> Help is appreciated very much! ______________________________________________ [hidden email] 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. |
|
I believe (unchecked) that you need OHLC data for candlesticks. You can use to.TTT functions to make some from your daily data.
Michael On Dec 21, 2011, at 11:52 PM, Adrian Berg <[hidden email]> wrote: > Both >> barChart(dataxts,bar.type='hlc') >> candleChart(dataxts) > give the same results as well. > > On Wed, Dec 21, 2011 at 11:15 PM, Adrian Berg <[hidden email]> wrote: >> Thanks to mrflick on Freenode, I was able to get chartSeries to plot the data. >> >> data$date<-strptime(data$date, format="%Y-%m-%d") >> dataxts<-xts(data$price, order.by=data$date) >> chartSeries(dataxts) >> >> chartSeries(dataxts, type="candlesticks") plots the same graph though: >> http://i.imgur.com/P0Jh0.png >> >> Why is this? >> >> On Wed, Dec 21, 2011 at 9:10 PM, Adrian Berg <[hidden email]> wrote: >>>> colnames = c("date","price") >>>> data = read.csv(file="data.csv", sep=",", header=F, nrows=261, skip=5, col.names=colnames) >>>> library(quantmod) >>>> data >>> date price >>> 1 2011-12-18 13.7825 >>> 2 2011-12-11 13.5500 >>> ... >>> ... >>> ... >>> 259 2007-01-07 10.8256 >>> 260 2006-12-31 10.8531 >>> 261 2006-12-24 10.8169 >>> >>> # Here's where I would like to use chartSeries from quantmod, but I'm >>> stumped, so I try several different things >>> >>>> chartSeries(date, price, data=data) >>> Error in try.xts(x, error = "chartSeries requires an xtsible object") : >>> chartSeries requires an xtsible object >>>> ?chartSeries >>>> chartSeries(date, price, type="candlesticks", theme = chartTheme("black")) >>> Error in try.xts(x, error = "chartSeries requires an xtsible object") : >>> chartSeries requires an xtsible object >>>> chartSeries(date, price, type="candlesticks", theme = chartTheme("black"), subset='2007::2008-01') >>> Error in try.xts(x, error = "chartSeries requires an xtsible object") : >>> chartSeries requires an xtsible object >>> >>> >>> Help is appreciated very much! > > ______________________________________________ > [hidden email] 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. ______________________________________________ [hidden email] 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. |
| Powered by Nabble | Edit this page |
