Description Usage Arguments Value Examples
Converts a data and time object to tid. Use this function to make a datatime object strptime( '02-01-1980 00:00:00', "%d-%m-%Y %H:%M:%S")
1 | nz_convert_datetime_to_tid(datetime, scale)
|
datetime |
a date and time value in string format like '2016-01-02 00:00:00'. It must be between "1000-01-01 00:00:00" and "3000-01-01 00:00:00" |
scale |
the scale for TID. Must be one the following items '1000y','500y','100y','50y','10y','1y','m','w','d','12h','6h','3h','h','min','s' |
TID in an Integer format
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
convert_datetime_to_tid(strptime( '02-01-1980 00:00:00', "%d-%m-%Y %H:%M:%S"),'1y')
#Another Example
start <- as.Date("01-01-1980",format="%d-%m-%Y")
end <- as.Date("01-01-2020",format="%d-%m-%Y")
theDate <- start
df <- data.frame()
names(df) <- c("time","tid")
while (theDate <= end)
{
t <- strptime(paste(format(theDate,"%d-%m-%Y")," 00:00:00"), "%d-%m-%Y %H:%M:%S")
tid <- convert_datetime_to_tid(t, "d")
print(tid)
df <- rbind(df, data.frame(time = t, tid = tid))
theDate <- seq.Date( theDate, length=2, by='1 years' )[2]
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.