[R] last day of month values

Joerg Maeder maeder at atmos.umnw.ethz.ch
Tue Feb 26 15:03:20 CET 2002


Hallo Lukas,

try this code
#data
d <-
data.frame(day=c(1,10,15,30,2,16,18,28),month=c(1,1,1,1,2,2,2,2),value=c(8,9,7,5,6,4,1,2))
#find the highest day per month
ma <- tapply(d$day,d$month,max)
#get them values
d$value[match(as.numeric(names(ma))+(ma-1)/31,d$month+(d$day-1)/31)]

gruess

joerg

Lukas Kubin wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> I have a stock market trading values time series. What's the best way to
> extract the "last day of month" values. I looked at function window() but
> doesn't appear suitable for this since it expects regular dates.
> Thank you.
> 
> lukas
> 
> - --
> Lukas Kubin
> lukas.kubin at permonik.com
> phone: 00420603836180
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.5 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
> 
> iD8DBQE8e2w74TIZ2lmUAtsRAj/SAJ4heMKveDwpCLPwnnJTBnAvCSIRrQCeJTHi
> YEujkKsmoX/orLUlnHxBNYA=
> =H9uw
> -----END PGP SIGNATURE-----
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
Joerg Maeder    .:|:||:..:.||.::   maeder at atmos.umnw.ethz.ch
Tel: +41 1 633 36 25   .:|:||:..:.||.::   
http://www.iac.ethz.ch/staff/maeder
PhD student at INSTITUTE FOR ATMOSPHERIC AND CLIMATE SCIENCE (IACETH)
ETH ZÜRICH Switzerland
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list