Discussion:
[Rcpp-devel] translate r to rcpp
rihab boubakri
2017-10-05 12:43:34 UTC
Permalink
hello please can any one help me to change that function to rcpp or cxxfunction please

for(i in 1:length(datafi$p)){
if(datafi$A[i] != "STOP"){
datafi$tran[i]=matt[[datafi$p[i+1]]][datafi$A[i],datafi$A[i+1]]
}
}
Dirk Eddelbuettel
2017-10-05 12:55:46 UTC
Permalink
On 5 October 2017 at 12:43, rihab boubakri wrote:
| hello please can any one help me to change that function to rcpp or cxxfunction please
|
| for(i in 1:length(datafi$p)){
| if(datafi$A[i] != "STOP"){
| datafi$tran[i]=matt[[datafi$p[i+1]]][datafi$A[i],datafi$A[i+1]]
| }
| }

What have you tried? What failed? What error did you get? What result were
you expecting?

Most of us have real work to do so asking us for free code writing service is
a wee bit much.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Serguei Sokol
2017-10-05 13:48:52 UTC
Permalink
Post by Dirk Eddelbuettel
| hello please can any one help me to change that function to rcpp or cxxfunction please
|
| for(i in 1:length(datafi$p)){
| if(datafi$A[i] != "STOP"){
| datafi$tran[i]=matt[[datafi$p[i+1]]][datafi$A[i],datafi$A[i+1]]
| }
| }
What have you tried? What failed? What error did you get? What result were
you expecting?
At least one potential error jumps out at you. If "STOP" is not the last item in datafi$A,
you will have "index out of range" for datafi$p[i+1] and datafi$A[i+1] when i=length(datafi$p).

Serguei.
Post by Dirk Eddelbuettel
Most of us have real work to do so asking us for free code writing service is
a wee bit much.
Dirk
Loading...