[R] Enquiries about time plots in R

Gabor Grothendieck ggrothendieck at gmail.com
Wed Nov 12 16:51:08 CET 2008


Try this (in reality you would use the commented line
in place of the subsequent line) and then read the three
zoo vignettes and R News 4/1.

library(zoo)
library(chron)
Lines <- "Date              pH
1/02/1998      5.5
5/03/1998      5
8/12/1998      6
1/02/1999      6.1
08/10/2000    7.2"

# z <- read.zoo("myfile.dat", header = TRUE, format = "%m/%d/%Y")
z <- read.zoo(textConnection(Lines), header = TRUE, format = "%m/%d/%Y")
plot(z)


On Wed, Nov 12, 2008 at 10:40 AM, Lathouri, Maria
<m.lathouri06 at imperial.ac.uk> wrote:
> Dear all,
>
> My name is Maria Lathouri and I am currently doing a PhD at Imperial College of London about time series of environmental variables in surface waters. I am trying to do some time plots with R but it seems that it is not working.
> The problem is that the time is not regular, for example, a small dataset can be seen below:
> Date              pH
> 1/02/1998      5.5
> 5/03/1998      5
> 8/12/1998      6
> 1/02/1999      6.1
> ...
> 08/10/2000    7.2
>
> I have used the function >plot(DATE, pH) and then >lines(pH), but the line does not join the points. I have used many combinations, e.g. >plot(DATE, pH) and then >lines(DATE, pH), where I get a plot with full of lines inside or just >plot(pH) and then >lines(pH) where the line connects the points but in x-axis I do not have the DATE. It says Index from 0 to 80.
>
> Do you know if there is a function where I can have in x-axis the DATE (irregular dates) and in y-axis the variable with a continuous line, showing how it changes through time?



More information about the R-help mailing list