Missing functions from chron package

160 Views Asked by At

The CRAN documentation for the chron package has the function trunc.times(). However, even after updating and reloading the chron package in R, no such function is found. Has this function been removed and the documentation just hasn't been updated yet? Are there more than one chron packages? Really need to find away to get that functionality.

Thanks

2

There are 2 best solutions below

2
On BEST ANSWER

The function is still there, but not exported. You need to use chron:::trunc.times (three colons).

If you really don't like those triple colons, you can get the function yourself using
trunc.times = getFromNamespace("trunc.times", "chron")

I don't know a good way to get a listing of internal functions that are not exported, but you can get a listing of what was imported when you loaded the package using
ls("package:chron")

0
On

trunc.times is a method associated with the trunc generic. You are supposed to call the generic, not the method directly. That is why the package does not export it.

Here is an example of how to use it.

library(chron)
trunc(times("01:01:01"), "hour")
## [1] 01:00:00

The Examples section of ?trunc.times has more examples.