[Rcpp-commits] r3879 - in pkg/RcppBDT: R demo man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Nov 1 04:10:07 CET 2012
Author: edd
Date: 2012-11-01 04:10:05 +0100 (Thu, 01 Nov 2012)
New Revision: 3879
Added:
pkg/RcppBDT/demo/RcppBDTdd.R
pkg/RcppBDT/man/bdtDd.Rd
Modified:
pkg/RcppBDT/R/zzz.R
pkg/RcppBDT/demo/00Index
pkg/RcppBDT/man/bdtDt.Rd
pkg/RcppBDT/man/bdtDu.Rd
Log:
added demo and manual page for bdtDd
complemented some more documentation
Modified: pkg/RcppBDT/R/zzz.R
===================================================================
--- pkg/RcppBDT/R/zzz.R 2012-11-01 02:42:28 UTC (rev 3878)
+++ pkg/RcppBDT/R/zzz.R 2012-11-01 03:10:05 UTC (rev 3879)
@@ -44,36 +44,21 @@
x
}) )
-.format_dd <- function(x, ...) format(as.difftime( x$getDays(), units="days"))
-.show_dd <- function(object) print(as.difftime( object$getDays(), units="days"))
-.format_dt <- function(x, ...) format(x$getDate(), ...)
-.show_dt <- function(object) print(object$getDate())
-
-.format_tz <- function(x, ...) format(x$getRegion(), ...)
-.show_tz <- function(object) print(object$getRegion())
-
-.format_pt <- function(x, ...) format(x$getDatetime(), ...)
-.show_pt <- function(object) print(object$getDatetime())
-
-.format_du <- function(x, ...) format(as.difftime( x$getTotalSeconds( ) + x$getFractionalSeconds( ) / 1.0e9 , units="secs"))
-.show_du <- function(object) print(as.difftime( object$getTotalSeconds( ) + object$getFractionalSeconds( ) / 1.0e9 , units="secs"))
-
-
## define an onLoad expression to set some methods
evalqOnLoad({
- setMethod("show", "Rcpp_bdtDt", .show_dt)
- setMethod("show", "Rcpp_bdtTz", .show_tz)
- setMethod("show", "Rcpp_bdtPt", .show_pt)
- setMethod("show", "Rcpp_bdtDu", .show_du)
- setMethod("show", "Rcpp_bdtDd", .show_dd)
+ setMethod("show", "Rcpp_bdtDt", function(object) print(object$getDate()))
+ setMethod("show", "Rcpp_bdtTz", function(object) print(object$getRegion()))
+ setMethod("show", "Rcpp_bdtPt", function(object) print(object$getDatetime()))
+ setMethod("show", "Rcpp_bdtDu", function(object) print(as.difftime(object$getTotalSeconds() + object$getFractionalSeconds() / 1.0e9, units="secs")))
+ setMethod("show", "Rcpp_bdtDd", function(object) print(as.difftime(object$getDays(), units="days")))
setGeneric("format", function(x,...) standardGeneric("format"))
- setMethod("format", "Rcpp_bdtDt", .format_dt)
- setMethod("format", "Rcpp_bdtTz", .format_tz)
- setMethod("format", "Rcpp_bdtPt", .format_pt)
- setMethod("format", "Rcpp_bdtDu", .format_du)
- setMethod("format", "Rcpp_bdtDd", .format_dd)
+ setMethod("format", "Rcpp_bdtDt", function(x, ...) format(x$getDate(), ...))
+ setMethod("format", "Rcpp_bdtTz", function(x, ...) format(x$getRegion(), ...))
+ setMethod("format", "Rcpp_bdtPt", function(x, ...) format(x$getDatetime(), ...))
+ setMethod("format", "Rcpp_bdtDu", function(x, ...) format(as.difftime(x$getTotalSeconds() + x$getFractionalSeconds() / 1.0e9, units="secs")))
+ setMethod("format", "Rcpp_bdtDd", function(x, ...) format(as.difftime( x$getDays(), units="days")))
setMethod("Arith", signature(e1 = "Rcpp_bdtDu", e2 = "Rcpp_bdtDu" ),
function(e1, e2) arith_bdtDu_bdtDu( e1, e2, .Generic ) )
Modified: pkg/RcppBDT/demo/00Index
===================================================================
--- pkg/RcppBDT/demo/00Index 2012-11-01 02:42:28 UTC (rev 3878)
+++ pkg/RcppBDT/demo/00Index 2012-11-01 03:10:05 UTC (rev 3879)
@@ -1,3 +1,5 @@
RcppBDT Boost Date.Time date functionality demo
RcppBDTtz Boost Date.Time timezone functionality demo
RcppBDTdu Boost Date.Time duration object demo
+RcppBDTpt Boost Date.Time posix time object demo
+RcppBDTdd Boost Date.Time date duration object demo
Added: pkg/RcppBDT/demo/RcppBDTdd.R
===================================================================
--- pkg/RcppBDT/demo/RcppBDTdd.R (rev 0)
+++ pkg/RcppBDT/demo/RcppBDTdd.R 2012-11-01 03:10:05 UTC (rev 3879)
@@ -0,0 +1,30 @@
+
+## demo for date duration objects
+
+require(utils, quiet=TRUE, warn=FALSE)
+require(Rcpp, quiet=TRUE, warn=FALSE)
+require(RcppBDT, quiet=TRUE, warn=FALSE)
+
+dd <- new(bdtDd, 5)
+print(dd) ## converts to difftime
+
+print(dd + dd) # date_duration + date_duration
+print(dd + 3)
+print(dd - 2)
+#print(2L + dd) # should work
+##print(2 - dd) # not permitted
+
+dt <- new(bdtDt, 2012, 10, 10)
+print(dt)
+#print(dd + dt)
+print(dt + dd)
+#print(dt - dd)
+
+print(dt + dd + days(3) + weeks(2))
+print(dt)
+dt$addMonths(2)
+dt$addYears(1)
+print(dt)
+
+## no converter from Date yet: today <- Sys.Date() # base R, provides Date
+## print(today + dd)
Added: pkg/RcppBDT/man/bdtDd.Rd
===================================================================
--- pkg/RcppBDT/man/bdtDd.Rd (rev 0)
+++ pkg/RcppBDT/man/bdtDd.Rd 2012-11-01 03:10:05 UTC (rev 3879)
@@ -0,0 +1,44 @@
+\name{bdtDd}
+\alias{bdtDd}
+\alias{Rcpp_bdtDd-class}
+\alias{show,Rcpp_bdtDd-method}
+\alias{format,Rcpp_bdtDd-method}
+\alias{arith_bdtDd_bdtDd}
+\alias{arith_bdtDd_bdtDt}
+\alias{arith_bdtDd_int}
+\alias{arith_int_bdtDd}
+\alias{compare_bdtDd_bdtDd}
+\alias{days}
+\alias{weeks}
+\docType{package}
+\title{Rcpp module bdtDd for binding of Boost Date_Time date duration functionality}
+\description{
+ The \verb{bdtDd} module is created using Rcpp modules and wraps a
+ helper class \verb{bdtDd} around Boost Date_time date duration
+ functionality provided by the Boost class \code{boost::gregorian::date_duration}.
+
+ New instances can be created using an integer for days of duration.
+}
+\usage{
+days(...)
+weeks(...)
+}
+\arguments{
+ \item{...}{suitable argument, often an integer, denoting one unit of the reference duration component}
+}
+\section{Method}{
+ \describe{
+ \item{show}{\code{signature(x = "Rcpp_bdtDd")}: prints a (BDTdd)
+ date duration class object}
+ \item{format}{\code{signature(x = "Rcpp_bdtDd")}: formats a (BDTdd)
+ date duration class object}
+ }
+}
+\details{
+ Please consult the Boost documentation for (copious) details on the
+ Date_Time library. See the Rcpp-modules vignette for details on Rcpp
+ modules.
+}
+\author{Dirk Eddelbuettel \email{edd at debian.org}}
+\references{Boost Date_Time: \url{http://www.boost.org/doc/html/date_time.html}}
+\keyword{package}
Modified: pkg/RcppBDT/man/bdtDt.Rd
===================================================================
--- pkg/RcppBDT/man/bdtDt.Rd 2012-11-01 02:42:28 UTC (rev 3878)
+++ pkg/RcppBDT/man/bdtDt.Rd 2012-11-01 03:10:05 UTC (rev 3879)
@@ -3,6 +3,10 @@
\alias{bdtDt}
\alias{show,Rcpp_bdtDt-method}
\alias{format,Rcpp_bdtDt-method}
+\alias{arith_bdtDt_bdtDd}
+\alias{arith_bdtDt_int}
+\alias{arith_int_bdtDt}
+\alias{compare_bdtDt_bdtDt}
\alias{Rcpp_bdtDt-class}
\docType{package}
\title{Rcpp module bdtDt for binding of Boost Date_Time Date functionality}
Modified: pkg/RcppBDT/man/bdtDu.Rd
===================================================================
--- pkg/RcppBDT/man/bdtDu.Rd 2012-11-01 02:42:28 UTC (rev 3878)
+++ pkg/RcppBDT/man/bdtDu.Rd 2012-11-01 03:10:05 UTC (rev 3879)
@@ -6,6 +6,7 @@
\alias{arith_bdtDu_bdtDu}
\alias{arith_bdtDu_bdtPt}
\alias{arith_bdtDu_int}
+\alias{arith_int_bdtDu}
\alias{compare_bdtDu_bdtDu}
\alias{hours}
\alias{microseconds}
More information about the Rcpp-commits
mailing list