[Rcpp-devel] error while incompatible types in assignment

nandan amar nandan.amar at gmail.com
Wed Mar 23 20:57:23 CET 2011


Hello,
I tried following code for copying data from an R array to C++ array
variable
------------------------------------------------------------------
#include <R.h>
#include <R_ext/Applic.h>
#include <Rinternals.h>
#include <RInside.h>
int main(int argc, char *argv[])
    {

    RInside R(argc, argv);
    float sum[50];//int sum[50];
     R.parseEvalQ("arr<-c(1:50)") ;
    for(int i=0;i<=50;i++)
    sum[i] = R["arr[i]"];
    for(int i=0;i<=50;i++)
    std::cout << "value: " << sum[i] << std::endl ;
    exit(0);
    }
-------------------------------------------------------------------------------
It got compiled and I got following error while running. Error is same for
sum[] to be int/float

terminate called after throwing an instance of 'Rcpp::not_compatible'
  what():  expecting a single value
Aborted



-- 
Amar Kumar Nandan
Karnataka, India, 560100
http://aknandan.co.nr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110324/08904cb9/attachment.htm>


More information about the Rcpp-devel mailing list