Question

I am using R.NET in IronPython in Visual Studio 2012. The code below works fine:

import clr
from System import *
from System.IO import *
clr.AddReferenceToFileAndPath("C:\\PythonDev\\MSP_Script\\Python\\MSP_Script\\RDotNet.dll")

from RDotNet import *

envPath = Environment.GetEnvironmentVariable("PATH")

rBinPath = "C:\\Program Files\\R\\R-3.0.2\\bin\\i386"
Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + rBinPath)

engine = REngine.CreateInstance("RDotNet")
engine.Initialize()

group2 = engine.Evaluate("group2 <- c(29.89, 29.93, 29.72, 29.98, 30.02, 29.98)")

But as soon as I add the following line of code:

group1 = engine.CreateNumericVector((30.02, 29.99, 30.11, 29.97, 30.01, 29.99))

I get the error "AttributeError: 'REngine' object has no attribute 'CreateNumericVector'"

If I run the same code in C# it works fine. I have Googled this for some time now and cant find any pointers. Any help would be much appreciated.

Was it helpful?

Solution

The method you are trying to call is not an actual member of REngine but an extension method as seen in the sources. If you add the following extension import it will work as expected:

from RDotNet import REngineExtension
clr.ImportExtensions(REngineExtension)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top