Description Author(s) Examples
This help file is to help in development of xts, as well as provide some clarity and insight into its purpose and implementation.
Last modified: 2013-01-16 by Jeffrey A. Ryan and Dirk Eddelbuettel Version: 0.9-2 and above
At present the xts API has publically available
interfaces to the following functions (as defined in xtsAPI.h
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | Callable from other R packages:
SEXP xtsIsOrdered(SEXP x, SEXP increasing, SEXP strictly)
SEXP xtsNaCheck(SEXP x, SEXP check)
SEXP xtsTry(SEXP x)
SEXP xtsRbind(SEXP x, SEXP y, SEXP dup)
SEXP xtsCoredata(SEXP x)
SEXP xtsLag(SEXP x, SEXP k, SEXP pad)
Internal use functions:
int isXts(SEXP x)
void copy_xtsAttributes(SEXP x, SEXP y)
void copy_xtsCoreAttributes(SEXP x, SEXP y)
Internal use macros:
xts_ATTRIB(x)
xts_COREATTRIB(x)
GET_xtsIndex(x)
SET_xtsIndex(x,value)
GET_xtsIndexClass(x)
SET_xtsIndexClass(x,value)
GET_xtsIndexFormat(x)
SET_xtsIndexFormat(x,value)
GET_xtsCLASS(x)
SET_xtsCLASS(x,value)
Internal use SYMBOLS:
xts_IndexSymbol
xts_ClassSymbol
xts_IndexFormatSymbol
xts_IndexClassSymbol
Callable from R:
SEXP mergeXts(SEXP args)
SEXP rbindXts(SEXP args)
SEXP tryXts(SEXP x)
|
Jeffrey A. Ryan
1 2 3 4 5 6 7 | ## Not run:
# some example code to look at
file.show(system.file('api_example/README', package="xts"))
file.show(system.file('api_example/src/checkOrder.c', package="xts"))
## End(Not run)
|
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
This directory contains a skeleton example
of how to link to the C-API
The basic requirements to use the exported xts
C code is:
(1) Add to your DESCRIPTION file:
Depends: xts
linkingTo: xts
(2) In your .c files:
#include "xtsAPI.h"
This header file exports the functions that are
public in xts.
(3) Compile as you would with any other package:
R CMD build api_example
R CMD INSTALL linkXTS_1.0.tar.gz
(4) Try it out!
R> require(linkXTS)
R> checkOrder(1:10)
[1] TRUE
R> checkOrder(c(1:10,1))
[1] FALSE
/*
Example of using the C API from xts in new package code
This is derived from examining the source of
packages Matrix and lme4.
*/
#include <R.h>
#include <Rinternals.h>
#include <Rdefines.h>
#include <R_ext/Rdynload.h> /* required by R */
/*
The following header file is from the include directory that is
included with xts
*/
#include "xtsAPI.h" /* function declaration and macros */
SEXP check_order (SEXP x, SEXP incr, SEXP strict)
{
SEXP ret;
PROTECT(ret = allocVector(LGLSXP, 1));
/*
do_is_ordered is imported from the xts package.
All that is needed here is to call it.
*/
ret = xtsIsOrdered(x, incr, strict);
UNPROTECT(1);
return ret;
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.