You might consider using the zoo package since it handles all this automatically:
library(zoo) z <- read.zoo("Data.txt", format = "%d/%m/%Y", header = TRUE) plot(z) plot(diff(log(z))) There are 3 vignettes that come with zoo with more info. On Mon, Feb 25, 2008 at 5:39 PM, Khadija Mohammedali <[EMAIL PROTECTED]> wrote: > > Hi Jim > > Thank you for your quick response. This worked great. I am having the same > problem again. I have moved on to calculating returns from rates and want to > plot returns on the y axis and again dates on the x axis. The code I am using > to calculate returns is as follows: > rate<-x$Rate > returns<-(diff(log(rate))) > If I do: > plot(returns, type="l") I get the graph I want however am having problems > with the x axis again. Modification of the code below doesnt work as I now > have one less dimension in returns. Hope I am making sense. Your help is > much appreciated. > > Date: Mon, 25 Feb 2008 16:32:44 -0500> From: [EMAIL PROTECTED]> To: [EMAIL > > PROTECTED]> Subject: Re: [R] Graph Axis> CC: r-help@r-project.org> > You > > have to convert you date to be a Date class:> > x <- > > read.table("/tempxx.txt", header=TRUE, as.is=TRUE)> x$Date <- > > as.Date(x$Date, "%d/%m/%Y")> plot(x$Date, x$Rate, type='l')> > > On > > 2/25/08, Khadija Mohammedali <[EMAIL PROTECTED]> wrote:> >> > Hi I have > > data of exchange rates and time, and am trying to draw a graph that will > > show the rates on the y axis and dates on the x axis. I am using the > > following code: plot(rate, type='l', xlab='Date', ylab='Rate', main='£ to > > Euro rate over 5 years')This gives me the graph I want although I want to > > display the dates on the x axis, even if its just 2002, 2003,...2008. > > Attached is my data. Hope you can help.> > > > _________________________________________________________________> > > > [[elided Hotmail spam]]> >> >> > > > ______________________________________________> > 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.> >> >> >> > > > > -- > Jim Holtman> Cincinnati, OH> +1 513 646 9390> > What is the problem > > you are trying to solve? Tell me what you want to> do, not how you want to > > do it. > _________________________________________________________________ > Free games, great prizes - get gaming at Gamesbox. > > [[alternative HTML version deleted]] > > > ______________________________________________ > 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.