[R] Example(chron) doesn't work
hchui
helena.chui at flinders.edu.au
Thu Oct 27 01:25:32 CEST 2011
It works with Rgui vanilla, R version 2.13.1. I'll check it again when I
install R version 2.13.2.
Many thanks!
> "C:\\Program Files\\R\\R-2.13.1\\bin\\x64\\Rgui.exe --vanilla"
[1] "C:\\Program Files\\R\\R-2.13.1\\bin\\x64\\Rgui.exe --vanilla"
> library(chron)
Warning message:
package 'chron' was built under R version 2.13.2
> example(chron)
chron> dts <- dates(c("02/27/92", "02/27/92", "01/14/92",
chron+ "02/28/92", "02/01/92"))
chron> dts
[1] 02/27/92 02/27/92 01/14/92 02/28/92 02/01/92
chron> # [1] 02/27/92 02/27/92 01/14/92 02/28/92 02/01/92
chron> tms <- times(c("23:03:20", "22:29:56", "01:03:30",
chron+ "18:21:03", "16:56:26"))
chron> tms
[1] 23:03:20 22:29:56 01:03:30 18:21:03 16:56:26
chron> # [1] 23:03:20 22:29:56 01:03:30 18:21:03 16:56:26
chron> x <- chron(dates = dts, times = tms)
chron> x
[1] (02/27/92 23:03:20) (02/27/92 22:29:56) (01/14/92 01:03:30)
[4] (02/28/92 18:21:03) (02/01/92 16:56:26)
chron> # [1] (02/27/92 23:03:19) (02/27/92 22:29:56) (01/14/92 01:03:30)
chron> # [4] (02/28/92 18:21:03) (02/01/92 16:56:26)
chron>
chron> # We can add or subtract scalars (representing days) to dates or
chron> # chron objects:
chron> c(dts[1], dts[1] + 10)
[1] 02/27/92 03/08/92
chron> # [1] 02/27/92 03/08/92
chron> dts[1] - 31
[1] 01/27/92
chron> # [1] 01/27/92
chron>
chron> # We can substract dates which results in a times object that
chron> # represents days between the operands:
chron> dts[1] - dts[3]
Time in days:
[1] 44
chron> # Time in days:
chron> # [1] 44
chron>
chron> # Logical comparisons work as expected:
chron> dts[dts > "01/25/92"]
[1] 02/27/92 02/27/92 02/28/92 02/01/92
chron> # [1] 02/27/92 02/27/92 02/28/92 02/01/92
chron> dts > dts[3]
[1] TRUE TRUE FALSE TRUE TRUE
chron> # [1] TRUE TRUE FALSE TRUE TRUE
chron>
chron> # Summary operations which are sensible are permitted and work as
chron> # expected:
chron> range(dts)
[1] 01/14/92 02/28/92
chron> # [1] 01/14/92 02/28/92
chron> diff(x)
Time in days:
[1] -0.02319444 -44.89335648 45.72052083 -27.05876157
chron> # Time in days:
chron> # [1] -0.02319444 -44.89335648 45.72052083 -27.05876157
chron> sort(dts)[1:3]
[1] 01/14/92 02/01/92 02/27/92
chron> # [1] 01/14/92 02/01/92 02/27/92
chron>
chron>
chron>
--
View this message in context: http://r.789695.n4.nabble.com/Example-chron-doesn-t-work-tp801580p3942640.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list