[R] last day of month values

Lukas Kubin lukas.kubin at permonik.com
Fri Mar 15 17:59:21 CET 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thank you, it works. But how do I deal with years? This finds just the
"maxdayspermonths" within a year. But my data are for more years. And the
maxday in month differs in years.
Thank you.

lukas

On Tue, 26 Feb 2002, Joerg Maeder wrote:

> Hi Lukas
>
> use the functions stpftime and strptime (see R documentation)
> eg: as.numeric(strftime(f,format="%m")) for the months, year: "%y", day:
> "%d"
> Be carefull about leadings 0 (3 or 03) and try to write the year in 4
> digits!
> if your date is a string you can use as.numeric(substring(date,from,
> length))
> eg: month <- as.numeric(substring(date,4,2))
>
>
> Lukas Kubin wrote:
> >
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Hi Joerg,
> > thank you for the answer, however I have the timestamp in format 26-02-02.
> > Do I have to extract each part of the date?
> > Thank you.
> >
> > lukas
> >
> > On Tue, 26 Feb 2002, Joerg Maeder wrote:
> >
> > > 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
> > > > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> > >
> > >
> >
> > - --
> > 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
> >
> > iD8DBQE8e5uJ4TIZ2lmUAtsRAuQXAKDCaNnEyXXVFa6fMS81klJIXDFrlgCgmm71
> > zVnHeNICrNs6dvQd0Ir1YkI=
> > =pcXi
> > -----END PGP SIGNATURE-----
>
>

- -- 
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

iD8DBQE8kiht4TIZ2lmUAtsRAlXYAJ9AXzlfmDeh6A1qQFuZPUyVr/nrOgCfaGMd
lgdIrgosXKzRjMNtKcqt/rA=
=ee3Z
-----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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list