[R] Month end calculations
price_ja at hotmail.com
Wed Aug 29 18:37:47 CEST 2007
A simple example (avoiding using dates, just to show the principle) - this
assumes that your data are already sorted (?order).
temp <- data.frame(subject = rep(1:2, each = 5), response = 1:10)
last <- do.call(rbind, by(temp, temp$subject, function(x) tail(x, 1)))
By changing the 2nd parameter to 'tail' you can get different numbers of
observations in the tail of each subset, so it has more power than SAS's
.last. If you need an equivalent of .first, then replace 'tail' with 'head'.
Shubha Vishwanath Karanth wrote:
> Hi R users,
> Is there a function in R, which does some calculation only for the month
> end in a daily data?... In other words, is there a command in R,
> equivalent to "last." function in SAS?
> BR, Shubha
> [[alternative HTML version deleted]]
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
View this message in context: http://www.nabble.com/Month-end-calculations-tf4347226.html#a12390874
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help