I am not 100% sure of what you want but maybe this will help. I have modified your example data to omit one point so that there is a holiday among the rows:
library(zoo) # read data Lines <- "Date Open High Low CloseNifty 2004-01-01 1880.35 1917.05 1880.35 1912.25 2004-01-02 1912.25 1951.70 1911.05 1946.05 # 2004-01-05 1946.30 1969.20 1930.75 1955.00 2004-01-06 1955.10 1979.05 1908.75 1926.70 2004-01-07 1927.95 1930.95 1888.10 1916.75 2004-01-08 1918.10 1973.45 1918.10 1968.55 2004-01-09 1969.00 2014.65 1957.45 1971.90 2004-01-12 1972.00 1980.55 1936.75 1945.60 2004-01-13 1944.70 1967.85 1926.10 1963.60 2004-01-14 1987.40 1995.20 1970.10 1982.15 2004-01-15 1983.20 2000.30 1933.25 1944.45 2004-01-16 1944.15 1953.05 1887.10 1900.65 2004-01-19 1901.90 1943.10 1874.95 1935.35 2004-01-20 1928.80 1957.65 1876.85 1893.25 2004-01-21 1895.45 1899.55 1811.35 1824.60 " # replace next line with: z <- read.zoo("myfile", header = TRUE) z <- read.zoo(textConnection(Lines), header = TRUE) # add NA wherever there is a missing day z <- as.zoo(as.ts(z)) time(z) <- as.Date(time(z)) z # remove weekends z <- z[format(time(z), "%w") %in% 1:5] z # interpolate z <- zoo(na.approx(coredata(z)), time(z)) z On 3/28/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hello All > > I have time series data like given hereinbelow :- > The data is having dates. I tried using ts() but it requires frequency. As > i have holidays, saturdays sunday market closed, and also sometimes the > data may not be recorded. I want to create a time series object but i want > that where ever the holiday is the except saturday/sunday then it should > impute the mean of previous and the next working day. I want to do this so > that i can perfectly say that 5 obs is my weekly frequency, 25 is my > monthly etc :- Please help in this regards > > > tui[1:15,] > Date Open High Low CloseNifty > 1 2004-01-01 1880.35 1917.05 1880.35 1912.25 > 2 2004-01-02 1912.25 1951.70 1911.05 1946.05 > 3 2004-01-05 1946.30 1969.20 1930.75 1955.00 > 4 2004-01-06 1955.10 1979.05 1908.75 1926.70 > 5 2004-01-07 1927.95 1930.95 1888.10 1916.75 > 6 2004-01-08 1918.10 1973.45 1918.10 1968.55 > 7 2004-01-09 1969.00 2014.65 1957.45 1971.90 > 8 2004-01-12 1972.00 1980.55 1936.75 1945.60 > 9 2004-01-13 1944.70 1967.85 1926.10 1963.60 > 10 2004-01-14 1987.40 1995.20 1970.10 1982.15 > 11 2004-01-15 1983.20 2000.30 1933.25 1944.45 > 12 2004-01-16 1944.15 1953.05 1887.10 1900.65 > 13 2004-01-19 1901.90 1943.10 1874.95 1935.35 > 14 2004-01-20 1928.80 1957.65 1876.85 1893.25 > 15 2004-01-21 1895.45 1899.55 1811.35 1824.60 > > > > Thanks a lot > -gaurav > > ============================================================================================ > DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{dropped}} > > ______________________________________________ > R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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.