extract_datetime: Extracts datetime from data frame

Description Usage Arguments Value See Also Examples

View source: R/extract-datetime.r

Description

Extracts datetime from data frame

Usage

1
2
3
extract_datetime(data, prefix = "^", suffix = "$", expand = c("Year",
  "Month", "Day", "Hour", "Minute", "Second"), tz = "PST",
  standardised_offset = -8)

Arguments

data

data.frame with columns of [prefix]expand[suffix], [prefix]expand[suffix] values etc

prefix

string

suffix

string

expand

character vector of column names where [prefix]expand[suffix] and expand must only be Year, Month, Day, Hour, Minute and/or Second

tz

string of time zone. Typical values are 'PST8PDT' if Pacific time i.e., includes daylight savings, 'PST' if Pacific standard time i.e. no daylight savings 'PDT' if Pacific dayight time i.e. all daylight savings and 'UTC' all in Universal Coordinated Time (GMT). 'PST8PDT' occurs when times are read from a watch, 'PST' occurs when loggers are deployed in pacific standard time (recommended) 'PDT' occurs when loggers are deployed in pacific daylight time without adjusting and 'UTC' occurs with non-adjusted Vemco receivers.

standardised_offset

an integer scalar indicating the time difference in hours between UTC and the desired time zone.

Value

A date time object

See Also

sql_datetime, ISOdatetime and extract_date

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data <- data.frame(Year = 2000, Month = 1:12, Day = 2,
                   Hour = 12, Minute = 30, Second = 1)
extract_datetime(data)
extract_date(data)
extract_time(data)

extract_datetime(data)
extract_datetime(data, tz = 'PDT')
extract_datetime(data, tz = 'PST8PDT')
extract_datetime(data, tz = 'UTC')
extract_datetime(data, standardised_offset = -7)

data <- data.frame(ReleaseYear = 2002, ReleasedMonth = 2, DayRel = 2,
                   RelHourRel = 2, Minute = 2, Second = 2, DupSecond = 3)

extract_datetime(data, '')
extract_datetime(data, '', '')

poissonconsulting/poiscon documentation built on Feb. 18, 2021, 11:16 p.m.