R.NET: Empty pdf vs. R: Working pdf

Aug 28, 2012 at 4:27 PM

Hi,

I wanted to create a small gui in order to enter some data from which R.NET should create a waterfall chart and print it to a pdf-file. The problem is: The pdf file which is created has no content, so there is actually no page which can be displayed.

In order to find the error, I copied the created R commands to the R gui and started a test. It worked absolutely fine and created a waterfall chart in a pdf file.

You can imagine how confusing this is. I hope someone can help me, so that I can work on with that little tool.

Some words to the code:
I first initialize the R-Engine, load some libraries and tell it to create a pdf of the next output. Then I build the data, which comes from a DataGridView. After that I build the commands which then will be passed to the R-Engine in order to create the waterfall chart.

engine.Initialize();
engine.Evaluate("library(latticeExtra)");
engine.Evaluate("library(waterfall)");
engine.Evaluate("pdf(file=\"c-sharp-test.pdf\")");

/* Read the data*/
...
   

/* Build the strings for the dataframe
...

engine.Evaluate("label = c(" + l + ")");
engine.Evaluate("value = c(" + v + ")");
engine.Evaluate("subtotal = c(" + g + ")");
engine.Evaluate("df = data.frame(label,value,subtotal)");
                engine.Evaluate("asTheEconomist(waterfallchart(value~label, data=df, groups=subtotal, main=\"P&L\"))");

engine.Evaluate("dev.off()");
engine.Close();

As I said, this code works, such that there is no ParsingError or whatsoever. The file which will be created has a certain file size which is similar to the file size of the pdf which can be created by the same commands in the R-gui. But there is no page in it.

Thanks for your help!

Daniel