I have the following list of observations of calendar time: [1] 03-Nov-1997 09-Oct-1991 27-Aug-1992 01-Jul-1994 19-Jan-1990 12-Nov-1993 [7] 08-Oct-1993 10-Nov-1982 08-Dec-1986 23-Dec-1987 02-Aug-1995 20-Oct-1998 [13] 29-Apr-1991 16-Mar-1994 20-May-1991 28-Dec-1987 14-Jul-1999 27-Nov-1998 [19] 09-Sep-1999 26-Aug-1999 20-Jun-1997 05-May-1995 26-Mar-1998 15-Aug-1994 [25] 24-Jun-1996 02-Oct-1996 12-Aug-1985 24-Jun-1992 09-Jan-1991 04-Mar-1988 3230 Levels: 01-Apr-1987 01-Apr-1990 01-Apr-1991 01-Apr-1996 ... 31-Oct-1998 I want to make a plot where x-axis is the calendar time and y-axix is the cumulative sum of observations observed on or before that dates. Can anyone give some suggestions? [[alternative HTML version deleted]]
On Wed, 2007-12-19 at 14:59 +0800, gallon li wrote:> I have the following list of observations of calendar time: > > [1] 03-Nov-1997 09-Oct-1991 27-Aug-1992 01-Jul-1994 19-Jan-1990 12-Nov-1993 > [7] 08-Oct-1993 10-Nov-1982 08-Dec-1986 23-Dec-1987 02-Aug-1995 20-Oct-1998 > [13] 29-Apr-1991 16-Mar-1994 20-May-1991 28-Dec-1987 14-Jul-1999 27-Nov-1998 > [19] 09-Sep-1999 26-Aug-1999 20-Jun-1997 05-May-1995 26-Mar-1998 15-Aug-1994 > [25] 24-Jun-1996 02-Oct-1996 12-Aug-1985 24-Jun-1992 09-Jan-1991 04-Mar-1988 > 3230 Levels: 01-Apr-1987 01-Apr-1990 01-Apr-1991 01-Apr-1996 ... 31-Oct-1998 > > I want to make a plot where x-axis is the calendar time and y-axix is the > cumulative sum of observations observed on or before that dates.Is this what you want? ## some example data dat <- cumsum(rnorm(100)) start.end <- as.Date(c("01/01/2007", "31/12/2007"), format = "%d/%m/%Y") dates <- seq(start.end[1], start.end[2], length = 100) ## plot the data plot(dat ~ dates, type = "l") HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Here is an example of plotting the number of observations per month. You can change this to any period you want. # create some test data x.d <- as.Date("2000-1-1") + runif(1000, 1, 500) # create buckets of one month (or whatever period you want) x.cut <- cut(x.d, breaks=seq(as.Date('2000-1-1'), max(x.d)+7, by="1 month")) # plot the data barplot(table(x.cut), main="Observations Per Month") On Dec 19, 2007 1:59 AM, gallon li <gallon.li at gmail.com> wrote:> I have the following list of observations of calendar time: > > [1] 03-Nov-1997 09-Oct-1991 27-Aug-1992 01-Jul-1994 19-Jan-1990 12-Nov-1993 > [7] 08-Oct-1993 10-Nov-1982 08-Dec-1986 23-Dec-1987 02-Aug-1995 20-Oct-1998 > [13] 29-Apr-1991 16-Mar-1994 20-May-1991 28-Dec-1987 14-Jul-1999 27-Nov-1998 > [19] 09-Sep-1999 26-Aug-1999 20-Jun-1997 05-May-1995 26-Mar-1998 15-Aug-1994 > [25] 24-Jun-1996 02-Oct-1996 12-Aug-1985 24-Jun-1992 09-Jan-1991 04-Mar-1988 > 3230 Levels: 01-Apr-1987 01-Apr-1990 01-Apr-1991 01-Apr-1996 ... 31-Oct-1998 > > I want to make a plot where x-axis is the calendar time and y-axix is the > cumulative sum of observations observed on or before that dates. > > Can anyone give some suggestions? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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?
I am not sure I really understand what you want but will this work? tt<-c("03-Nov-1997","09-Oct-1991","27-Aug-1992","01-Jul-1994","19-Jan-1990", "12-Nov-1993","08-Oct-1993","10-Nov-1982","08-Dec-1986","23-Dec-1987","02-Aug-1995", "20-Oct-1998","29-Apr-1991","16-Mar-1994","20-May-1991","28-Dec-1987","14-Jul-1999", "27-Nov-1998","09-Sep-1999","26-Aug-1999","20-Jun-1997","05-May-1995","26-Mar-1998", "15-Aug-1994","24-Jun-1996","02-Oct-1996","12-Aug-1985","24-Jun-1992","09-Jan-1991", "04-Mar-1988") tt1 <- as.Date(tt, "%d-%b-%Y")) aa <- cumsum(1:length(tt)) plot(tt1,aa) --- gallon li <gallon.li at gmail.com> wrote:> I have the following list of observations of > calendar time: > > [1] 03-Nov-1997 09-Oct-1991 27-Aug-1992 01-Jul-1994 > 19-Jan-1990 12-Nov-1993 > [7] 08-Oct-1993 10-Nov-1982 08-Dec-1986 23-Dec-1987 > 02-Aug-1995 20-Oct-1998 > [13] 29-Apr-1991 16-Mar-1994 20-May-1991 28-Dec-1987 > 14-Jul-1999 27-Nov-1998 > [19] 09-Sep-1999 26-Aug-1999 20-Jun-1997 05-May-1995 > 26-Mar-1998 15-Aug-1994 > [25] 24-Jun-1996 02-Oct-1996 12-Aug-1985 24-Jun-1992 > 09-Jan-1991 04-Mar-1988 > 3230 Levels: 01-Apr-1987 01-Apr-1990 01-Apr-1991 > 01-Apr-1996 ... 31-Oct-1998 > > I want to make a plot where x-axis is the calendar > time and y-axix is the > cumulative sum of observations observed on or before > that dates. > > Can anyone give some suggestions? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >