p_excel_dt: Parse Excel Numeric Date/Time

Description Usage Arguments Details Value See Also Examples

View source: R/p_excel_date.R

Description

Parse Excel Numeric Date/Time

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
p_excel_dt(x)

## Default S3 method:
p_excel_dt(x)

## S3 method for class 'numeric'
p_excel_dt(x)

## S3 method for class 'Date'
p_excel_dt(x)

## S3 method for class 'POSIXct'
p_excel_dt(x)

## S3 method for class 'character'
p_excel_dt(x)

Arguments

x

numeric; vector of Excel date/times expressed as numeric

Details

At times readxl::read_excel does not get the date and times right and imports them as numeric instead. This converts those numeric date/times to proper Date or POSIXct objects.

Value

A Date object if x is integer; a POSIXct object if x is numeric.

See Also

read_excel

Examples

1
2
3
4
5
6
7
8
  p_excel_dt( 40000 )
  p_excel_dt( c(40000,NA)) 
  p_excel_dt( Sys.Date() )
  p_excel_dt( Sys.time() )   
  
  p_excel_dt( c("12/1/2016 12:01 PM") )
  p_excel_dt( c("12/1/2016 12:01 PM", "12/1/2016", NA, "Unparsable", "4365") )
  

decisionpatterns/coercion documentation built on Nov. 4, 2019, 10:23 a.m.