I have converted my sampling algorithm in R to a Rcpp. The Rcpp code is compiling, but giving an error when calling the function from R Error in eval(expr, envir, enclos) : index out of bounds". traceback() is also not informative.

7: stop(list(message = "index out of bounds", call = eval(expr, 
   envir, enclos), cppstack = NULL))  
6: .Call("temp1_eeSNP_regress", PACKAGE = "temp1", x, y, feature, 
   alpHa, gamMa_prob, beTa, estimate_alpha, estimate_beta, B_inv_alpHa, 
   itermax, thin, burnIn)  
5: eeSNP_regress(x = e.obj$x, y = e.obj$y, feature = e.obj$feature, 
   alpHa = e.obj$alpHa, beTa = e.obj$beTa, gamMa_prob = e.obj$gamMa.prob, 
   estimate_alpha = F, estimate_beta = T, B_inv_alpHa = rep(1/100, 
       dim(e.obj$feature)[2] + 1), itermax = 5000, thin = 40, 
   burnIn = 1000) at cmd.R#1  
4: eval(expr, envir, enclos)  
3: eval(ei, envir)  
2: withVisible(eval(ei, envir))

Is there a way to debug such runtime error in Rcpp rather than throwing bunch of cout? Is it possible to call gdb inside R?

有帮助吗?

解决方案

Yes, you can use gdb with R.

See for example Section 4.4 "Debugging Compiled Code" in the Writing R Extentions manual.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top