C# : can't execute code from R -


i want show ellipse in c#. codes fine when running in r message c# : "object static; operation not allowed (exception hresult: 0x8004000b (ole_e_static))"

here codes :

df.rconn.evaluate("library(cluster)") df.rconn.evaluate("library(rrcov)") public void setscatter(int xaxis, int yaxis, int zaxis, list<string> variable)      {          // plot r         //to show outlier method : classic & robust mve          this.comboboxxaxis.selectedindex = xaxis;         this.comboboxyaxis.selectedindex = yaxis;         dataform.rconn.evaluatenoreturn("x<-x[," + xaxis + "] ");         dataform.rconn.evaluatenoreturn("y<-x[," + yaxis + "] ");         dataform.rconn.evaluatenoreturn("shape <- cov(x)");         dataform.rconn.evaluatenoreturn("center<- colmeans(x)");         dataform.rconn.evaluatenoreturn("d2.95 <- qchisq(0.95, df = 2)");         //dataform.rconn.evaluatenoreturn("gr<- grid(lty=3,col='lightgray', equilogs = 'true')");         //dataform.rconn.evaluate("mtext('with classical (red) , robust (blue)')");         dataform.rconn.evaluatenoreturn("plot(x,y, main='draw ellipse ', pch=19,col='black', type='p')");         dataform.rconn.evaluatenoreturn("elp<- unname(ellipsoidpoints(shape, d2.95,center))");         dataform.rconn.evaluate(" lines(elp, col='red' , lty=7 , lwd=2)");         //dataform.rconn.evaluatenoreturn("lines(e)");         //dataform.rconn.evaluatenoreturn("lines(ellipsoidpoints(mve@cov, d2 = d2.95, loc=mve@center), col='blue', lty='7' , lwd='2') ");         axgraphicsdevice2.removefromconnector();     } 

in code comment got same error. don't know why problem happen. idea how show ellipse ? thank because have helped me in completing thesis.

some missing contextual information, going provide guess "rconn" (statconnector?) not happy when operations refresh graphic device (lines, mtext, etc.).

as needed test r graphic stuff c# (with r.net) own purposes, used code basis , propose workaround try. you'll find sample console application works, using r.net, on github under: https://github.com/jmp75/rdotnet-support/tree/master/samples/drawellipse

compiled/run vs2013, windows7 64 bits, .net framework 4.5.

i noticed needed optionally use dev.hold , dev.flush intuitive refreshes.

e.evaluate("dev.hold()"); e.evaluate("mtext('with classical (red) , robust (blue)')"); e.evaluate("dev.flush()"); 

hope helps.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -