[Rcpp-commits] r816 - pkg/RcppExamples/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Mar 2 03:10:54 CET 2010
Author: edd
Date: 2010-03-02 03:10:54 +0100 (Tue, 02 Mar 2010)
New Revision: 816
Added:
pkg/RcppExamples/R/RcppDateExample.R
pkg/RcppExamples/R/RcppParamsExample.R
pkg/RcppExamples/R/RcppVectorExample.R
Modified:
pkg/RcppExamples/R/RcppExample.R
Log:
move R functions for example into their own files
Added: pkg/RcppExamples/R/RcppDateExample.R
===================================================================
--- pkg/RcppExamples/R/RcppDateExample.R (rev 0)
+++ pkg/RcppExamples/R/RcppDateExample.R 2010-03-02 02:10:54 UTC (rev 816)
@@ -0,0 +1,49 @@
+
+## RcppDateExample.R: Rcpp R/C++ interface class library RcppDate example
+##
+## Copyright (C) 2008 Dirk Eddelbuettel
+## Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Romain Francois
+##
+## This file is part of Rcpp.
+##
+## Rcpp is free software: you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 2 of the License, or
+## (at your option) any later version.
+##
+## Rcpp is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+RcppDateExample <- function(dv, dtv) {
+
+ ## Check that params is properly set.
+ if (missing(dv)) {
+ cat("\nIn R, setting default argument for dv\n")
+ dv <- Sys.Date() + -2:2
+ }
+
+ if (missing(dtv)) {
+ cat("\nIn R, setting default argument for dtv\n")
+ dtv <- Sys.time() + (-2:2)*0.5
+ }
+
+ ## Make the call...
+ val <- .Call("RcppDateExample",
+ dv, dtv,
+ PACKAGE="RcppExamples")
+
+ ## Define a class for the return value so we can control what gets
+ ## printed when a variable assigned this value is typed on a line by itself.
+ ## This has the effect of calling the function print.RcppExample(). The
+ ## function (defined below) simply prints the names of the fields that are
+ ## available. Access each field with val$name.
+ class(val) <- "RcppExample"
+
+ val
+}
+
Modified: pkg/RcppExamples/R/RcppExample.R
===================================================================
--- pkg/RcppExamples/R/RcppExample.R 2010-03-02 02:06:23 UTC (rev 815)
+++ pkg/RcppExamples/R/RcppExample.R 2010-03-02 02:10:54 UTC (rev 816)
@@ -102,79 +102,3 @@
}
}
-RcppParamsExample <- function(params) {
-
- ## Check that params is properly set.
- if (missing(params)) {
- cat("\nIn R, setting default argument for params\n")
- params <- list(method='BFGS',
- tolerance=1.0e-8,
- maxIter=1000,
- startDate=as.Date('2006-7-15'))
- }
-
- ## Make the call...
- val <- .Call("RcppParamsExample",
- params,
- PACKAGE="RcppExamples")
-
- ## Define a class for the return value so we can control what gets
- ## printed when a variable assigned this value is typed on a line by itself.
- ## This has the effect of calling the function print.RcppExample(). The
- ## function (defined below) simply prints the names of the fields that are
- ## available. Access each field with val$name.
- class(val) <- "RcppExample"
-
- val
-}
-
-RcppDateExample <- function(dv, dtv) {
-
- ## Check that params is properly set.
- if (missing(dv)) {
- cat("\nIn R, setting default argument for dv\n")
- dv <- Sys.Date() + -2:2
- }
-
- if (missing(dtv)) {
- cat("\nIn R, setting default argument for dtv\n")
- dtv <- Sys.time() + (-2:2)*0.5
- }
-
- ## Make the call...
- val <- .Call("RcppDateExample",
- dv, dtv,
- PACKAGE="RcppExamples")
-
- ## Define a class for the return value so we can control what gets
- ## printed when a variable assigned this value is typed on a line by itself.
- ## This has the effect of calling the function print.RcppExample(). The
- ## function (defined below) simply prints the names of the fields that are
- ## available. Access each field with val$name.
- class(val) <- "RcppExample"
-
- val
-}
-
-RcppVectorExample <- function(v) {
-
- ## Check that params is properly set.
- if (missing(v)) {
- cat("\nIn R, setting default argument for v\n")
- v <- seq(1,9)^2
- }
-
- ## Make the call...
- val <- .Call("RcppVectorExample",
- v,
- PACKAGE="RcppExamples")
-
- ## Define a class for the return value so we can control what gets
- ## printed when a variable assigned this value is typed on a line by itself.
- ## This has the effect of calling the function print.RcppExample(). The
- ## function (defined below) simply prints the names of the fields that are
- ## available. Access each field with val$name.
- class(val) <- "RcppExample"
-
- val
-}
Added: pkg/RcppExamples/R/RcppParamsExample.R
===================================================================
--- pkg/RcppExamples/R/RcppParamsExample.R (rev 0)
+++ pkg/RcppExamples/R/RcppParamsExample.R 2010-03-02 02:10:54 UTC (rev 816)
@@ -0,0 +1,47 @@
+
+## RcppParamsExample.R: Rcpp R/C++ interface class library RcppParams example
+##
+## Copyright (C) 2008 Dirk Eddelbuettel
+## Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Romain Francois
+##
+## This file is part of Rcpp.
+##
+## Rcpp is free software: you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 2 of the License, or
+## (at your option) any later version.
+##
+## Rcpp is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+RcppParamsExample <- function(params) {
+
+ ## Check that params is properly set.
+ if (missing(params)) {
+ cat("\nIn R, setting default argument for params\n")
+ params <- list(method='BFGS',
+ tolerance=1.0e-8,
+ maxIter=1000,
+ startDate=as.Date('2006-7-15'))
+ }
+
+ ## Make the call...
+ val <- .Call("RcppParamsExample",
+ params,
+ PACKAGE="RcppExamples")
+
+ ## Define a class for the return value so we can control what gets
+ ## printed when a variable assigned this value is typed on a line by itself.
+ ## This has the effect of calling the function print.RcppExample(). The
+ ## function (defined below) simply prints the names of the fields that are
+ ## available. Access each field with val$name.
+ class(val) <- "RcppExample"
+
+ val
+}
+
Added: pkg/RcppExamples/R/RcppVectorExample.R
===================================================================
--- pkg/RcppExamples/R/RcppVectorExample.R (rev 0)
+++ pkg/RcppExamples/R/RcppVectorExample.R 2010-03-02 02:10:54 UTC (rev 816)
@@ -0,0 +1,43 @@
+
+## RcppVectorExample.R: Rcpp R/C++ interface class library RcppVector example
+##
+## Copyright (C) 2008 Dirk Eddelbuettel
+## Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Romain Francois
+##
+## This file is part of Rcpp.
+##
+## Rcpp is free software: you can redistribute it and/or modify it
+## under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 2 of the License, or
+## (at your option) any later version.
+##
+## Rcpp is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+RcppVectorExample <- function(v) {
+
+ ## Check that params is properly set.
+ if (missing(v)) {
+ cat("\nIn R, setting default argument for v\n")
+ v <- seq(1,9)^2
+ }
+
+ ## Make the call...
+ val <- .Call("RcppVectorExample",
+ v,
+ PACKAGE="RcppExamples")
+
+ ## Define a class for the return value so we can control what gets
+ ## printed when a variable assigned this value is typed on a line by itself.
+ ## This has the effect of calling the function print.RcppExample(). The
+ ## function (defined below) simply prints the names of the fields that are
+ ## available. Access each field with val$name.
+ class(val) <- "RcppExample"
+
+ val
+}
More information about the Rcpp-commits
mailing list