Created
December 8, 2012 17:18
-
-
Save wush978/4241083 to your computer and use it in GitHub Desktop.
Normalization of xts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(xts) | |
library(inline) | |
library(Rcpp) | |
#' normalization | |
#' | |
#' This function will normalize the input \code{Rxts}. | |
#' | |
#' @param Rxts xts object which will be normalize | |
#' @return NULL | |
normalize_xts <- rcpp(sig=c(Rxts="xts"), body=' | |
NumericMatrix xts(Rxts); | |
double base_value; | |
for(int i = 0;i < xts.nrow();i++) { | |
base_value = xts(i, 0); | |
xts.row(i) = xts.row(i) - base_value; | |
xts.row(i) = xts.row(i) / base_value; | |
} | |
') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment