[R] call lm function in R

shkurta ahmeti shkurtaahmeti at yahoo.de
Sat Feb 28 20:03:33 CET 2009

Hello everybody,

i have to make a c++ programm, which calls the function lm() in R. Therefore i installed the rcpp-package. There were some examples too. 

I tried something, but i have the problem with the SEXP structure:

I want to call lm() without coming from R:

class MyVectorFunc : public RcppFunction {
	MyVectorFunc() : RcppFunction( new SEXP(mkChar( "lm" )) {}

	funtkionsaufrufer( vector<double>& v )
		SEXP result = vectorCall();
		double value = REAL(result)[0];
		return value;


RcppFunction is from the Rcpp-package and this needs a SEXP-parameter. How can i create lm() as a SEXP parameter.

I m very thankful for every answer.


More information about the R-help mailing list