Thanks for your posting, Gabor. I liked your creative use of zoo-related 
functions, and I learned something from your example.

The example wouldn't run on my machine, unfortunately, so I made some changes. 
If other people have difficulties, too, perhaps my version will work for them. 
(I also made some cosmetic changes.) Here it is:

library(zoo)

# Create synthetic data
DF <- data.frame(date = as.Date(0:999), value = cumsum(rnorm(1000)))

# Create columns for year and
# julian day-of-the-year (1st, 2nd, ..., Nth day of the year)
DF$year <- cut(DF$date, "year")
DF$jul <- ave(DF$value, factor(DF$year), FUN = seq)

# Create a list of vectors: each vector contains the values for one year
f <- factor(DF$year)
values <- split(DF$value, f)

# Create a list of vector: each vector contains the julian days for one year
julians <- split(DF$jul, f)

# Combine each pair of vectors (values and days), creating zoo objects
zz <- lapply(seq_along(values), function(i) zoo(values[[i]], julians[[i]]))
z <- do.call(merge.zoo, zz)
colnames(z) <- substr(levels(f),1,4)

# Plot the zoo objects:
#    Use plot.type="single" to have all columns in the same frame
#    Use plot.type="multiple" to get separate plots
colors <- 1:ncol(z)
plot(z, screens=1, col = colors, plot.type="single")
legend("bottomright", leg = substr(levels(f), 1, 4), fill = colors)


Paul Teetor, Elgin, IL  USA
http://quanttrader.info/public




________________________________
From: Gabor Grothendieck <ggrothendieck@gmail.com>
To: SNV Krishna <snvk4u@gmail.com>
Cc: "r-sig-finance@stat.math.ethz.ch" <r-sig-finance@stat.math.ethz.ch>
Sent: Mon, August 2, 2010 11:31:43 AM
Subject: Re: [R-SIG-Finance] Seasonal plot of daily data

On Mon, Aug 2, 2010 at 11:28 AM, SNV Krishna <snvk4u@gmail.com> wrote:
> Hi All,
>
> I have daily closing prices of a particular commodity. I would like to generate 
>annual plot of the series so as to get a visual feel of the seasonality across 
>years.
>
> For ex I have crude oil daily price data since 2002. I would like to have 
>multiple lines on a single plot, each line represents each year and plotted 
>against day of year on x-axis. I tried reading the data as zoo or xts objects, 
>but unable to plot multiple series on a single plot. Can any one help me out in 
>this regard?
>
> Thanks in advance for the help, rgds
>

Try this:

library(zoo)

# input data
DF <- data.frame(date = as.Date(0:999), value = 1:1000)

# create columns for year and
# julian day (1st, 2nd, ... day of the year)

DF$year <- cut(DF$date, "year")
DF$jul <- ave(DF$value, DF$year, FUN = seq_along)

# split into 1 col per year. year is col 2. index is col 3.
z <- read.zoo(DF[-1], index = 3, split = 2)

# plot - screen = 1 causes all columns to be in same frame
colors <- 1:ncol(z)
plot(z, screen = 1, col = colors)
legend("bottomright", leg = substr(levels(DF$year), 1, 4), fill = colors)

_______________________________________________
R-SIG-Finance@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

	[[alternative HTML version deleted]]

