can't plot in a file

Mar 5, 2013 at 11:39 AM
Hello,
I need to plot a graph from R to file using c# on x86 machine (Visual Studio 2010). I tried to follow example from http://rdotnet.codeplex.com/discussions/353150 but file wasn't created.
Here is my code:
        var envPath = System.Environment.GetEnvironmentVariable("PATH");
        var rBinPath = @"C:\Temp\test\R-lib";
        System.Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + rBinPath);
        REngine.SetDllDirectory(@"C:\Temp\test\R-lib");            

        REngine engine = REngine.CreateInstance("RDotNet");                
        engine.Evaluate("bmp(file='C:\\Temp\\test\\img\\blah.bmp'); plot.ts(rnorm(100));");
        engine.Dispose();
But everything is fine when I execute the same command in R console
Could you please help me to find where is my error?
Developer
Mar 9, 2013 at 10:09 PM
Works for me. I think you overlook something I noticed with R when writing graphics to files: the information is not written until you either call plot to write to another file (with Cairo drivers writting to a succession of files) or you close the device with dev.off().
bmp('f:/tmp/bmptest.bmp')
plot(rnorm(200)) # only creates an empty file on disk
dev.off()  # This is the call that causes the information to be written to the file.