RInside Version 0.2.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rinside_sample9.cpp
Go to the documentation of this file.
1 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*-
2 //
3 // Simple example showing how expose a C++ function -- no longer builds
4 //
5 // Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
6 
7 #include <RInside.h> // for the embedded R via RInside
8 
9 // a c++ function we wish to expose to R
10 std::string hello( std::string who ){
11  std::string result( "hello " ) ;
12  result += who ;
13  return result;
14 }
15 
16 int main(int argc, char *argv[]) {
17 
18  // create an embedded R instance
19  RInside R(argc, argv);
20 
21  // expose the "hello" function in the global environment
22  R["hello"] = Rcpp::InternalFunction( &hello ) ;
23 
24  // call it and display the result
25  std::string result = R.parseEvalNT("hello(\"world\")") ;
26  std::cout << "hello( 'world') = " << result << std::endl ;
27 
28  exit(0);
29 }
30 
Proxy parseEvalNT(const std::string &line)
Definition: RInside.cpp:388
std::string hello(std::string who)
int main(int argc, char *argv[])