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) print(temp) last <- do.call(rbind, by(temp, temp$subject, function(x) tail(x, 1))) print(last) 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'. Jim. 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@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. > > -- 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. ______________________________________________ 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.