Quantcast
Channel: R.NET
Viewing all 1634 articles
Browse latest View live

Created Unassigned: NullReference exception when using CharacterDevice [154]

$
0
0
I tried updating to the latest version of R.NET in RProvider, but I keep getting an exception when running R provider on Mac (this might be failing on Windows too, but I only tried on Mac). Version 1.5.19 does not work, but version 1.5.19 works.

R provider initialises REngine with custom CharacterDevice to capture the output. When we later run some command that prints (I think), we get the following error:

```
[13/01/2015 17:36:24] [Pid:2240, Tid:1, Apid:0] eval(fsr_2240_1('grDevices'))
[13/01/2015 17:36:24] [Pid:2240, Tid:1, Apid:0] Output:
[13/01/2015 17:36:24] [Pid:2240, Tid:1, Apid:0] Operation failed:
System.NullReferenceException: Object reference not set to an instance of an object
at RDotNet.Devices.CharacterDeviceAdapter.WriteConsoleEx (System.String buffer, Int32 length, ConsoleOutputType outputType) [0x00000] in <filename unknown>:0
at RDotNet.Devices.CharacterDeviceAdapter.WriteConsole (System.String buffer, Int32 length) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) object:wrapper_native_0x109a04670 (intptr)
at RDotNet.REngine.Parse (System.String statement, System.Text.StringBuilder incompleteStatement) [0x00000] in <filename unknown>:0
at RDotNet.REngine+<Defer>d__0.MoveNext () [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Last[SymbolicExpression] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.LastOrDefault[SymbolicExpression] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
at RDotNet.REngine.Evaluate (System.String statement) [0x00000] in <filename unknown>:0
at RProvider.RInteropInternal+eval@292.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <filename unknown>:0
at RProvider.Internal.Logging.logWithOutput[SymbolicExpression] (RProvider.CharacterDeviceInterceptor characterDevice, Microsoft.FSharp.Core.FSharpFunc`2 f) [0x00000] in <filename unknown>:0

```

I can dig deeper and probably give you a concrete repro for this, but I thought I'd share the error message first to see if you can think of any change that might be causing this...

Edited Issue: NullReference exception when using CharacterDevice [154]

$
0
0
I tried updating to the latest version of R.NET in RProvider, but I keep getting an exception when running R provider on Mac (this might be failing on Windows too, but I only tried on Mac). Version 1.5.19 does not work, but version 1.5.19 works.

R provider initialises REngine with custom CharacterDevice to capture the output. When we later run some command that prints (I think), we get the following error:

```
[13/01/2015 17:36:24] [Pid:2240, Tid:1, Apid:0] eval(fsr_2240_1('grDevices'))
[13/01/2015 17:36:24] [Pid:2240, Tid:1, Apid:0] Output:
[13/01/2015 17:36:24] [Pid:2240, Tid:1, Apid:0] Operation failed:
System.NullReferenceException: Object reference not set to an instance of an object
at RDotNet.Devices.CharacterDeviceAdapter.WriteConsoleEx (System.String buffer, Int32 length, ConsoleOutputType outputType) [0x00000] in <filename unknown>:0
at RDotNet.Devices.CharacterDeviceAdapter.WriteConsole (System.String buffer, Int32 length) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) object:wrapper_native_0x109a04670 (intptr)
at RDotNet.REngine.Parse (System.String statement, System.Text.StringBuilder incompleteStatement) [0x00000] in <filename unknown>:0
at RDotNet.REngine+<Defer>d__0.MoveNext () [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Last[SymbolicExpression] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.LastOrDefault[SymbolicExpression] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
at RDotNet.REngine.Evaluate (System.String statement) [0x00000] in <filename unknown>:0
at RProvider.RInteropInternal+eval@292.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <filename unknown>:0
at RProvider.Internal.Logging.logWithOutput[SymbolicExpression] (RProvider.CharacterDeviceInterceptor characterDevice, Microsoft.FSharp.Core.FSharpFunc`2 f) [0x00000] in <filename unknown>:0

```

I can dig deeper and probably give you a concrete repro for this, but I thought I'd share the error message first to see if you can think of any change that might be causing this...

Commented Issue: NullReference exception when using CharacterDevice [154]

$
0
0
I tried updating to the latest version of R.NET in RProvider, but I keep getting an exception when running R provider on Mac (this might be failing on Windows too, but I only tried on Mac). Version 1.5.19 does not work, but version 1.5.19 works.

R provider initialises REngine with custom CharacterDevice to capture the output. When we later run some command that prints (I think), we get the following error:

```
[13/01/2015 17:36:24] [Pid:2240, Tid:1, Apid:0] eval(fsr_2240_1('grDevices'))
[13/01/2015 17:36:24] [Pid:2240, Tid:1, Apid:0] Output:
[13/01/2015 17:36:24] [Pid:2240, Tid:1, Apid:0] Operation failed:
System.NullReferenceException: Object reference not set to an instance of an object
at RDotNet.Devices.CharacterDeviceAdapter.WriteConsoleEx (System.String buffer, Int32 length, ConsoleOutputType outputType) [0x00000] in <filename unknown>:0
at RDotNet.Devices.CharacterDeviceAdapter.WriteConsole (System.String buffer, Int32 length) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) object:wrapper_native_0x109a04670 (intptr)
at RDotNet.REngine.Parse (System.String statement, System.Text.StringBuilder incompleteStatement) [0x00000] in <filename unknown>:0
at RDotNet.REngine+<Defer>d__0.MoveNext () [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.Last[SymbolicExpression] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.LastOrDefault[SymbolicExpression] (IEnumerable`1 source) [0x00000] in <filename unknown>:0
at RDotNet.REngine.Evaluate (System.String statement) [0x00000] in <filename unknown>:0
at RProvider.RInteropInternal+eval@292.Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <filename unknown>:0
at RProvider.Internal.Logging.logWithOutput[SymbolicExpression] (RProvider.CharacterDeviceInterceptor characterDevice, Microsoft.FSharp.Core.FSharpFunc`2 f) [0x00000] in <filename unknown>:0

```

I can dig deeper and probably give you a concrete repro for this, but I thought I'd share the error message first to see if you can think of any change that might be causing this...
Comments: What version of Mono are you using? I had some similar sounding cases using the rClr package with R.NEt enabled under the hood, and scary cases where the mono debugger was telling me that this == null was true where 'this' was a character console (or the adapter). I do not recall that I found what the root cause was, but an upgrade of Mono was the most likely. I'll try to give a spin to the latest RProvider on Windows and Linux. I'd like to learn F# on the job, but my day job lately is mostly C++, with a bit of interop with R and C#.

New Post: Returning a time series to .net using r packages xts or zoo.

$
0
0
My modification of your sample code looks like this:
static void Main(string[] args)
{
    var rEngine = REngine.GetInstance();
    const string command = "library(xts); IndexValues <- xts(rnorm(10), Sys.Date()+1:10)";
    var df = rEngine.Evaluate(command).AsDataFrame();
}
You are correct, RDotNet is returning null. The issue is that IndexValues is an 'xts' object and is not a dataframe. I assume that you expected RDotNet to coerce the type for you in the same way 'as.data.frame()' would, but it does not.

As currently implemented, RDotNet's .AsDataFrame() exists to let the C# representation of the "IndexValues" object know that it is a C# DataFrame if and only if its already a R DataFrame.

You can see that for yourself here: https://github.com/jmp75/rdotnet/blob/2d54edfb68b98f81da70aeb450e5bdffcdc055c7/R.NET/SymbolicExpressionExtension.cs#L79

As is, I don't see a simple way to coerce a type to a dataframe from the C API, so your best bet is to call 'as.data.frame' from the R code.

New Post: Returning a time series to .net using r packages xts or zoo.

$
0
0
Thank you for your reply. That is what I was thinking yesterday. I modified my code and determined that when converted to a dataframe, r.net sees dates as a numericvector:
        string command = "IndexValues <- xts(rnorm(10), Sys.Date()+1:10)";
        rEngine.Evaluate(command).AsDataFrame();

        command = "data.frame(Date = index(IndexValues), IndexValues, row.names=NULL)";
        var df1 = rEngine.Evaluate(command).AsDataFrame();
df returns two columns, both numeric vectors. It does not see the date field as a date. I understand the number is an offset from 1/1/1970, but unless I know to look for the date fields by name, I can't programmatically create a generic import into a dataset. I think I am missing something easy. Any help would be appreciated. Thanks again.

New Post: Returning a time series to .net using r packages xts or zoo.

$
0
0
Its not that easy, getting types sent from R over to C# when the C# side can't predeclare them is difficult. I know there's some dynamic stuff for DataFrames, but I know little about it. On the static side, you need to do something like this. I'm sure there's alternative ways to make this work, but here's mine:
[DataFrameRow]
public class RowData
{
    [DataFrameColumn("Date")]
    public double Date { get; set; }

    [DataFrameColumn("IndexValues")]
    public double IndexValues { get; set; }
}
private static void Main(string[] args)
{
    var rEngine = REngine.GetInstance();
    const string command = @"library(xts); IndexValues <- xts(rnorm(10), as.POSIXlt(Sys.Date()+1:10));
                            data.frame(Date = index(IndexValues), IndexValues, row.names=NULL)";
    var df1 = rEngine.Evaluate(command).AsDataFrame();

    var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
    var dates = df1.GetRows<RowData>().Select(s => epoch.AddSeconds(s.Date)).ToList();
}

New Post: Returning a time series to .net using r packages xts or zoo.

$
0
0
Not much to add to what @skyguy94 has in terms of sample code. I would highly recommend that for date-time structures you use with R.NET that you:
  • Use POSIXct date/times
  • Use UTC date/times
For triangulation, code similar in spirit to the above can be found in:
https://github.com/jmp75/rClr/blob/master/src/ClrFacade/ClrFacade.cs
via:
publicstatic DateTime CreateDateFromRPOSIXct(double rDateNumericValue);
In my day job I work a lot with time series, and I like xts. I think I considered improving R.NET facilities, but refrained from it knowing what a can of worm date-time handling is. I spent a lot of time adding support for date-time and time zones (and its unit testing) in the rClr package. Basically my intent is to port only the very unambigious part to R.NET, and I think that may mean only facilities for UTC annd POSIXtc. Predictability and correctness before convenience.

If you want more details and pointers to information about date and time systems, you can skim through https://github.com/jmp75/rClr/blob/master/inst/tests/test-datetime.r

New Post: Returning a time series to .net using r packages xts or zoo.

$
0
0
@jmp75 Has anyone ever thought about adding a TypeConverter parameter to the attribute? It seems like a canonical way to reduce some of the awkwardness of pushing the conversion directly on the calling code.

New Post: Serialize object from R

$
0
0
Hi,

I use R.Net and greate gml datamining model. Then I do sth like that:

var model = engine.GetSymbol("full.logit");

Now I would like to serialize this model object to be able to use it next time I run the app but I get an error:

Type 'RDotNet.SymbolicExpression' in Assembly 'RDotNet, Version=1.5.19.20628, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

so is there any other way I can persist objects from R session?

New Post: Serialize object from R

$
0
0
RDotNet.SymbolicExpression is effectively a sort of pointer to an address in memory; it is by nature very difficult to impossible to make it serializable. You have to use the save/load functions in R and get the symbol in each session.
engine.Evaluate("save(full.logit, file='c:/path/to/myfile.rda')");
In another session:
engine.Evaluate("load(file='c:/path/to/myfile.rda')");
var model = engine.GetSymbol("full.logit"); 

Created Unassigned: Object reference not set to an instance of an object. [155]

$
0
0
Hi everyone,

I transferred my code from one machine to another and on the new machine, I get the following error: ":Object reference not set to an instance of an object."
It happens at "using"
REngine.SetDllDirectory(args[1]);
__using__ (REngine engine = REngine.CreateInstance("RDotNet", new[] { "-q" })) // quiet mode
{

R.Net is in the references.
args[1] is the folder in which the r.dll is located.

I use version 1.4.1.0 of R.NET.

Thank you for your help,
Julien

Commented Unassigned: Object reference not set to an instance of an object. [155]

$
0
0
Hi everyone,

I transferred my code from one machine to another and on the new machine, I get the following error: ":Object reference not set to an instance of an object."
It happens at "using"
REngine.SetDllDirectory(args[1]);
__using__ (REngine engine = REngine.CreateInstance("RDotNet", new[] { "-q" })) // quiet mode
{

R.Net is in the references.
args[1] is the folder in which the r.dll is located.

I use version 1.4.1.0 of R.NET.

Thank you for your help,
Julien
Comments: As a first guess, is R installed on that machine?

Commented Unassigned: Object reference not set to an instance of an object. [155]

$
0
0
Hi everyone,

I transferred my code from one machine to another and on the new machine, I get the following error: ":Object reference not set to an instance of an object."
It happens at "using"
REngine.SetDllDirectory(args[1]);
__using__ (REngine engine = REngine.CreateInstance("RDotNet", new[] { "-q" })) // quiet mode
{

R.Net is in the references.
args[1] is the folder in which the r.dll is located.

I use version 1.4.1.0 of R.NET.

Thank you for your help,
Julien
Comments: yes

Commented Unassigned: Object reference not set to an instance of an object. [155]

$
0
0
Hi everyone,

I transferred my code from one machine to another and on the new machine, I get the following error: ":Object reference not set to an instance of an object."
It happens at "using"
REngine.SetDllDirectory(args[1]);
__using__ (REngine engine = REngine.CreateInstance("RDotNet", new[] { "-q" })) // quiet mode
{

R.Net is in the references.
args[1] is the folder in which the r.dll is located.

I use version 1.4.1.0 of R.NET.

Thank you for your help,
Julien
Comments: I found R was installed but downloaded on another computer. I downloaded it on the given VM and it works now Thanks for your help, Julien

New Post: R.NET can not get instance at server


Commented Unassigned: Object reference not set to an instance of an object. [155]

$
0
0
Hi everyone,

I transferred my code from one machine to another and on the new machine, I get the following error: ":Object reference not set to an instance of an object."
It happens at "using"
REngine.SetDllDirectory(args[1]);
__using__ (REngine engine = REngine.CreateInstance("RDotNet", new[] { "-q" })) // quiet mode
{

R.Net is in the references.
args[1] is the folder in which the r.dll is located.

I use version 1.4.1.0 of R.NET.

Thank you for your help,
Julien
Comments: Happy to help.

Commented Issue: resizing plots generated from console using R.Net causes application to crash [153]

$
0
0
See http://stackoverflow.com/questions/27612311/resizing-plots-generated-using-r-net-causes-application-to-crash
Comments: I also ran into this issue with a F# console application. The code works as expected when evaluated in the F# Interactive window, but crashes when attempting to zoom or resize the device window when the application is run. I've published some code that reproduces this issue on my machine here: https://rdnetwi153.codeplex.com/ Let me know if you need any other information. OS: Windows 8.1 .NET 4.5 R.NET.Community 1.5.20 DynamicInterop 0.7.2.0 Setup in VS2013: 1. New project (FSharp > Console Application) 2. NuGet -> Install-Package R.NET.Community

Created Unassigned: R.net is not functional under iis7 [156]

$
0
0
Hi

We have installed R engine 3.1.2 on IIS7 on windows 2008R2 32 bit.

When the page is executed in the website in IIS7, it generates "This Page can't be displayed". Many times it stops the application pool but not always.

When the page is executed in debug mode in visual studio without any breakpoint, it just closes the page.

When the page is executed in debug mode in visual studio in single stepping at REngine.GetInstance, it generates error "Function Evaluation timeout".

Any idea how to solve this issue.

bool is64Bit = Environment.Is64BitProcess;
string archFolder = is64Bit ? @"\x64" : @"\i386";
string rPath = @"C:\Program Files\R\R-3.1.2\bin" + archFolder;
string rHome = @"C:\Program Files\R\R-3.1.2";
REngine.SetEnvironmentVariables(rPath, rHome);

REngine engine = REngine.GetInstance();

Kartik Patel

Commented Unassigned: R.net is not functional under iis7 [156]

$
0
0
Hi

We have installed R engine 3.1.2 on IIS7 on windows 2008R2 32 bit.

When the page is executed in the website in IIS7, it generates "This Page can't be displayed". Many times it stops the application pool but not always.

When the page is executed in debug mode in visual studio without any breakpoint, it just closes the page.

When the page is executed in debug mode in visual studio in single stepping at REngine.GetInstance, it generates error "Function Evaluation timeout".

Any idea how to solve this issue.

bool is64Bit = Environment.Is64BitProcess;
string archFolder = is64Bit ? @"\x64" : @"\i386";
string rPath = @"C:\Program Files\R\R-3.1.2\bin" + archFolder;
string rHome = @"C:\Program Files\R\R-3.1.2";
REngine.SetEnvironmentVariables(rPath, rHome);

REngine engine = REngine.GetInstance();

Kartik Patel
Comments: There's a well known issue with running R under IIS via RDotNet. You'll ened to add the R bin\arch folder to your system PATH and reboot your machine. See the issue here: https://rdotnet.codeplex.com/workitem/117

Commented Issue: resizing plots generated from console using R.Net causes application to crash [153]

$
0
0
See http://stackoverflow.com/questions/27612311/resizing-plots-generated-using-r-net-causes-application-to-crash
Comments: Great! Thanks! I can reproduce that easily. I need to find my Windows debug build of R and we'll get to the bottom of this.
Viewing all 1634 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>