Zählen Sie die Anzahl der Freitage oder Montage im Monat in R
Ich möchte eine Funktion, die die Anzahl der bestimmten Tage pro Monat zählt.
d. h. November '13 -> 5 freitags .. während Dezember '13 4 freitags zurückkehren würde ..
Gibt es eine elegante Funktion, die dies zurückgeben würde?
library(lubridate)
num_days <- function(date){
x <- as.Date(date)
start = floor_date(x, "month")
count = days_in_month(x)
d = wday(start)
sol = ifelse(d > 4, 5, 4) #estimate that is the first day of the month is after Thu or Fri then the week will have 5 Fridays
sol
}
num_days("2013-08-01")
num_days(today())
Was wäre ein besserer Weg, um dies zu tun?