R/days.R

days <- function(date=NULL) {

  if ( !(class(date)[1] %in% c("Date","POSIXct","POSIXlt")) )
    stop("Only Date, POSIXct and POSIXlt class dates")

  UseMethod("days")
 
}


days.Date <- function(date) {
    as.numeric(format(date, "%d"))
}

days.POSIXct <- function(date) {
    as.numeric(format(date, "%d"))
}

days.POSIXlt <- function(date) {
    date$mday
}

Try the yapomif package in your browser

Any scripts or data that you put into this service are public.

yapomif documentation built on May 2, 2019, 4:51 p.m.