Learn R Programming

ETAS (version 0.7.2)

date2day: Convert date-time data to numeric data in decimal days

Description

A function to convert date-time data to decimal days with respect to a date-time origin.

Usage

date2day(dates, start=NULL, tz="", ...)

Value

A numeric vector of the same length as dates.

Arguments

dates

A date-time or date object. Typically, it is a character vector containing date-time information.

start

A date-time or date object. Determines the origin of the conversion.

tz

Optional. Timezone specification to be used for the conversion.

...

Arguments to be passed to as.POSIXlt.

Author

Abdollah Jalilian jalilian@razi.ac.ir

Details

The arguments dates and start must be of appropriate format to be passed to as.POSIXlt function.

See Also

as.POSIXlt and difftime for appropriate format of the data to be converted.

Examples

Run this code
  # date-time data of Iran's earthquakes between 1973/01/01 and 2016/01/01
  dt <- paste(iran.quakes$date, iran.quakes$time)
  # origin of the conversion
  start <- "1973/01/01 00:00:00"
  # time in days since 1973-01-01 (UTC)
  date2day(dt, start, tz="GMT")

Run the code above in your browser using DataLab