[R] Need Advice with C# Program to Create and Display Cusum Chart

Dieter Menne dieter.menne at menne-biomed.de
Fri Jan 25 19:39:48 CET 2008

 <ngottlieb <at> marinercapital.com> writes:

> I need to write a C# program to create and display Cusum chart from any
> of the packages,
> spc, qcc or strucchange.
> 1-The data resides in a MS SQL Database. The C# program will handle
>   obtaining the data for the requisite types of samples.

It is easy to read SQL databases directly from R via RODBC. It's fast enough
even for long time series I usually read in.
> 1-How can I call the cusum capabilities of any of the above packages
>   and pass the data to the cusum function and plot?

cumsum is such an easy beast, that I would not bother R when the data are read
in from C(++,#,plain), and calculate it in compiled language instead.
> 2-How can from the C# program, obtain the returned data
>   and display the plotted chart in my C# program?
> 3- Displaying the chart in the C# program and allowing it to be saved is
> important.

Using .NET with R is not straightforward. You could use the DCOM interface which
needs some time to get used to. You could also write a wrapper DLL in C that can
be called. I have done this, but I only would do it again if on both sides I had
functionality that is powerful enough not to be ported (or with inaccessible

My suggestion is: stay within R for reading and processing, export the charts 
to files and display these in C# applications that read the file. Maybe you
could even use a browser for it. I have heard the argument "file is too slow" in
that context: be sure, it isn't, and your programming life is over too soon to
think in seconds.

Or, do everything in C#. Plotting cumsum is probably not the feature where R is
superior to other environments.


More information about the R-help mailing list