// -*- Mode:C++; Coding:us-ascii-unix; fill-column:160 -*-
/**************************************************************************************************************************************************************/
/**
@file      riValues.cpp
@author    Mitch Richling <https://www.mitchr.me>
@Copyright Copyright 2015 by Mitch Richling.  All rights reserved.
@date      2015-MM-DD
@brief     How to run R code and get the resulting values back into C++.@EOL
@Keywords  rinside examples r cran package c++ hello world
@Std       C++11

The real stuff is here. 
*/

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <RInside.h>                                                     /* RInside                 R pkg    */

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[]) {

  RInside R(argc, argv);                                        // create an embedded R instance

  double valueS = R.parseEval("3.141592653 + 1.414213562;");    // Evaluate some R code and get a scalar value back

  std::cout << "valueS = " << valueS << std::endl;  

  std::vector<double> valueV =  R.parseEval("1:10;");           // Evaluate some R code and get a vector value back

  std::cout << "valueV = [ ";
  for(auto x : valueV) 
    std::cout << x << " ";
  std::cout << "]" << std::endl;
 
  exit(0);
}