[R] How to extract last value in each group
Noah Silverman
noahsilverman at ucla.edu
Wed Aug 14 21:56:15 CEST 2013
Hello,
I have some stock pricing data for one minute intervals.
The delivery format is a bit odd. The date column is easily parsed and used as an index for an its object. However, the time column is just an integer (1:1807)
I just need to extract the *last* entry for each day. Don't actually care what time it was, as long as it was the last one.
Sure, writing a big nasty loop would work, but I was hoping that someone would be able to suggest a faster way.
Small snippet of data below my sig.
Thanks!
--
Noah Silverman, M.S., C.Phil
UCLA Department of Statistics
8117 Math Sciences Building
Los Angeles, CA 90095
--------------------------------------------------------------------------
Date Time O H L C U D
06/01/2010 1358 136.40 136.40 136.35 136.35 2 12
06/01/2010 1359 136.40 136.50 136.35 136.50 9 6
06/01/2010 1400 136.45 136.55 136.35 136.40 8 7
06/01/2010 1700 136.55 136.55 136.55 136.55 1 0
06/02/2010 331 136.55 136.70 136.50 136.70 36 6
06/02/2010 332 136.70 136.70 136.65 136.65 3 1
06/02/2010 334 136.75 136.75 136.75 136.75 1 0
06/02/2010 335 136.80 136.80 136.80 136.80 4 0
06/02/2010 336 136.80 136.80 136.80 136.80 8 0
06/02/2010 337 136.75 136.80 136.75 136.80 1 2
06/02/2010 338 136.80 136.80 136.80 136.80 3 0
More information about the R-help
mailing list