[R-sig-finance] ts-plotting?
p.kostov at Queens-Belfast.AC.UK
p.kostov at Queens-Belfast.AC.UK
Tue Nov 16 10:41:18 CET 2004
The reason is simple: IBM in your example is a data frame, while
EuStockMarkets is a time series object. (use str(XXX) to check this). To
get the date you may wish to transform IBM to ts (use e.g. as.ts())
On Nov 16 2004, ebashi wrote:
> Dear R users, I have just started R and already fascinated by its power.
> As this is my first email, I want to thank you all in advance and
> appreciate your efforts for helping others.
>
> I have a problem to plot Time in x-axis and as I was looking in email
> archives, I found out that other people also have had some problems with
> it before. To make it short and simple, I use the same examples in
> fBasics package, I imported IBM data as follow,
>
> > ## yahooImport -
> > xmpBasics("\nNext: IBM Shares from Yahoo > ")
> > # [test 19/20 century change 01-12-1999 -- 31-01-2000]
> > IBM = yahooImport(
> + query = "s=IBM&a=11&b=1&c=1999&d=0&q=31&f=2000&z=IBM&x=.csv",
> + try = TRUE)
>
> > if (!is.null(IBM)) print(IBM[1:6, ])
> Open High Low Close Volume Adj. Close*
> 19991201 102.56 104.44 102.25 103.42 5340000 100.15
> 19991202 103.44 106.31 103.37 105.27 6220800 101.94
> 19991203 109.81 112.87 107.94 111.87 14680500 108.33
> 19991206 113.00 116.50 112.50 116.00 9933000 112.33
> 19991207 117.00 119.19 115.44 116.62 11329500 112.93
> 19991208 116.25 121.00 115.50 118.28 8145300 114.54
>
>
> the dates in the first column don't have header and I don't know what
> type of data they are. when I plot them as follow,
> >tsPlot(IBM$Close)
>
> the x-axis has the row number ( I want to have Time in the x-axis)
>
> but when I use the example for the tsPlot from the fBasics which is as
> follows,
> > tsPlot(IBM$Open)
> > ## tsPlot -
> > xmpBasics("\nStart: European Stock Markets > ")
> > # Show multiple plot:
> > par(mfrow = c(1, 1), cex = 0.7)
> > data(EuStockMarkets)
> > tsPlot(EuStockMarkets, gpars = list(col = c(2:4, 6)), labels = FALSE)
> > title(main = "European Stock Markets")
> (this is how EuStockMarkets look like)
> > if (!is.null(IBM)) print(EuStockMarkets[1:6, ])
> DAX SMI CAC FTSE
> [1,] 1628.75 1678.1 1772.8 2443.6
> [2,] 1613.63 1688.5 1750.5 2460.2
> [3,] 1606.51 1678.6 1718.0 2448.2
> [4,] 1621.04 1684.1 1708.1 2470.4
> [5,] 1618.16 1686.6 1723.1 2484.7
> [6,] 1610.61 1671.6 1714.3 2466.8
>
> on the x-axis I get actual time values, I will appreciate it if someone
> help me regarding that and also clarify it for me what is the difference
> between these two type of data.
>
> Sincerely Yours,
>
> Arshia
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>
More information about the R-sig-finance
mailing list