<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hello I am new to Rcpp, and am looking to translate some for loops in R to C++ using Rcpp, but I am sort of stuck at the first hurdle, as the simple tutorials do not really seem to deal with xts structures.<div><br></div><div>The closest I found for some help online was found here (<a href="http://gallery.rcpp.org/articles/accessing-xts-api/">http://gallery.rcpp.org/articles/accessing-xts-api/</a>) but that seems to only give xts outputs rather than taking in xts inputs. Below is a mock example of R code that has a function and takes an xts object as an input and gives an xts object as an output.</div><div><br></div><div><div>toy.xts <- function(xtsobj,val.vec){</div><div>  xtsobj1 <- xtsobj</div><div>  for(i in 1:nrow(xtsobj1)){</div><div>    if((i %/% 3)==3 ){</div><div>      xtsobj1[i,"B"] <- val.vec[1]</div><div>    } else {</div><div>      xtsobj1[i,c("C","D")] <- val.vec+1</div><div>    }</div><div>  }</div><div>  xtsobj1</div><div>}</div><div><br></div><div>tmp.xts <- xts(matrix(c(1:500),ncol=5),Sys.Date()-c(1:100))</div><div>colnames(tmp.xts) <- LETTERS[1:5]</div><div>tmp.vec <- c(0.4,0.9)</div><div>toy.xts(tmp.xts,tmp.vec)</div></div><div><br></div><div>I know that this isn’t exactly the use case for converting R code, to C++, but I’m not too sure where to start when dealing with these different/non-simple structures as inputs. Apologies if this is very simple. </div><div><br></div><div>Would the RcppXts packages help at all? It doesn’t seem to have a huge number of functions, and am not too sure how to use it?</div><div><br></div><div>Thanks in advance</div><div><br></div><div>HLM</div></body></html>