Description Usage Arguments Details Value Author(s) See Also Examples
Converts time stamps from string to POSIXlt
. The conversion specification (pattern) is looked up if not given as argument.
1 2 |
timestamp |
Time stamp as string vector. |
pattern |
Conversion specification of time stamp as string (optional). See Details for usage. |
tz |
Optional character string specifying the time zone to be used for the conversion. System-specific (see |
If the time stamp is already formatted as POSIXlt
, the usage of timestamp
is not necessary. strptime
can also be used to create an applicable time stamp. Usage of timestamp
is recommeded, since it checks the created time stamp, thus faulty time stamps are avoided.
Pattern
A conversion specification is introduced by "%", usually followed by a single letter. Any character in the format string not part of a conversion specification is interpreted literally. Widely implemented conversion specifications include:
%d
: day of the month as decimal number (01–31)
%m
: month as decimal number (01–12)
%y
: year without century (00–99), where values 00–68 are prefixed by 20 and 69–99 by 19
%Y
: year with century
%H
: hour as decimal number (00–23)
%M
: minute as decimal number (00–59)
%S
: second as decimal number (00–61)
For details see strptime
.
Returns a POSIXlt
vector.
Christian Graul
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ## Not run:
# load and prepare data
data("winddata", package="bReeze")
# format time stamp
timestamp <- timestamp(timestamp=winddata[,1])
# format time stamp with given pattern
timestamp.2 <- timestamp(timestamp=winddata[,1], "%d.%m.%Y %H:%M")
# wrong pattern (
timestamp.2 <- timestamp(timestamp=winddata[,1], "%d.%m.%y %H:%M")
# strange time stamp pattern
ts <- c("TS 08/2012-10 8h10m30s", "TS 08/2012-10 8h20m30s",
"TS 08/2012-10 8h30m30s")
timestamp.3 <- timestamp(timestamp=ts) # pattern not found
timestamp.3 <- timestamp(timestamp=ts, "TS %m/%Y-%d %Hh%Mm%Ss")
# time zones
# manually define time zone
timestamp.4 <- timestamp(timestamp=winddata[,1], tz="CET")
# get time zone from timestamp
timestamp.5 <- timestamp(timestamp="2012-08-08 22:55 GMT", tz="?")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.