Date formats:
Remember the functions:
d <- as.Date(c("1937-01-10","1916-03-02","1913-09-19","1927-12-23","1947-07-28"))
quarters(d)
[1] "Q1" "Q1" "Q3" "Q4" "Q3"
# ... or as function
quarter <- function (x) {
# Berechnet das Quartal eines Datums
y <- as.numeric( format( x, "%Y") )
paste(y, "Q", (as.POSIXlt(x)$mon)%/%3 + 1, sep = "")
}
# ... or alternatively with cut
cut(d, breaks="quarters")
[1] 1937-01-01 1916-01-01 1913-07-01 1927-10-01 1947-07-01
137 Levels: 1913-07-01 1913-10-01 1914-01-01 1914-04-01 ... 1947-07-01
months(d)
[1] "Januar" "März" "September" "Dezember" "Juli"
format(d,"%B") # months alternative
[1] "Januar" "März" "September" "Dezember" "Juli"
format(d,"%Y") # years
[1] "1937" "1916" "1913" "1927" "1947"
Donnerstag, 8. September 2011
Abonnieren
Kommentare zum Post (Atom)
Keine Kommentare:
Kommentar veröffentlichen