Try creating a zoo object from your data frame # data from your post DF <- structure(list(Date = as.integer(c(20061122, 20061115, 20061108, 20061101, 20061025, 20061018, 20061011, 20061004, 20060927)), IBM = as.integer(c(12, 12, 12, 12, 12, 12, 11, 12, 10)), MSFT = as.integer(c(4, 4, 4, 4, 4, 4, 3, 3, 3))), .Names = c("Date", "IBM", "MSFT"), class = "data.frame", row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9"))
library(zoo) # create zoo object z from DF z <- zoo(as.matrix(DF[-1]), as.Date(as.character(DF$Date), "%Y%m%d")) diff(z, arith = FALSE)-1 # or perhaps diff(log(z)) Check out the zoo vignette vignette("zoo") On 11/29/06, iqbal hussain <[EMAIL PROTECTED]> wrote: > Hi, > > I am new to this, can anyone help. > > I am working with matrices, with stocknames as colNames and dates as > rowNames. > The data coontains percentile ranking for the stocks. > > Date IBM MSFT 20061122 12 4 20061115 12 4 > 20061108 > 12 4 20061101 12 4 20061025 12 4 20061018 12 4 20061011 > 11 3 20061004 12 3 20060927 10 3 > > I would like to calculate the rolling-rate-of-change of these ranking. > > I tried searching for second-derivative/slope/trend/etc to no avail. > > thanks in advance. > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.