Learn R Programming

pkdata (version 0.1.0)

parse_dates: Parse Date and Date-Time Variables

Description

Given a vector of dates or date-times, create Date or POSIXct variables.

Usage

parse_dates(x, tz = getOption("pkdata.tz", ""))

Arguments

x

character vector of dates or date-times

tz

character string; specifies the time zone to be used for the conversion. Defaults to the current time zone.

Value

vector of Date or POSIXct objects

Details

parse_dates calls parse_date_time from the lubridate package. While parse_date_time accepts multiple date formats, parse_dates requires a consistent format.

Examples

Run this code
# NOT RUN {
x <- c("2014-01-15", "20140202")
parse_dates(x)
x <- c("2014-01-15 01:51", "20140202 04:35:18")
parse_dates(x)
# }

Run the code above in your browser using DataLab