util_conv: conversion functions

Description Usage Details Examples

Description

kantar time (hhmmss or "hh:mm:ss") to seconds since 00:00:00 e.g: 110304 or "11:03:04" -> 39784

Usage

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

s2t(x, as = "t")

i2d(x, as = "c")

d2i(date, to = c("yyyymmdd", "yymmdd", "ddmmyyyy")[1])

date2file(dates, type = c("dem", "live", "tsv", "prg"))

file2date(path, type = TRUE, ext = c(dem = "dem", swo = "live", swd =
  "tsv", std = "program"))

asci2i(x)

Details

if(is.character(x)) x <- as.numeric(gsub(':',”,x)) # no slowdown hour <- trunc(x / 1e4) min <- trunc((x - hour * 1e4) / 1e2) sec <- x - hour * 1e4 - min * 1e2 as.integer(hour * 3600 + min * 60 + sec)

Examples

1
2
3
4
5
6
date <- c("2014-02-28","2016-11-03")
x <- as.integer(gsub('-', '', date))
yy <- x %/% 1e4L
mm <- x %% 1e4L %/% 1e2L
dd <- x %% 1e2L
dd * 1e6L + mm * 1e4L + yy

rluech/tv-clone documentation built on Jan. 7, 2022, 12:27 a.m.