Hi, I'm trying to combine a VBA macro and a R package. I've installed the R-(D)COM and the R-excel interface by Neuwirth. They seem to work both. However I would like to display the r-generated data in an Excel sheet as an array but I don't manage. Here is an example of my source: Sub doR() Call RInterface.StartRServer Call RInterface.RRun("library(mdnn)") Call RInterface.RRun("F11b1<-read.table(""c:/test/Testb1.txt"", header=TRUE)") Call RInterface.RRun("passTestb1<-pass(Testb1, Threshold=5, ExtremeThreshold=5)") Call RInterface.RRun("passTestb1") Call RInterface.getArray("passTestb1", Range("D2")) Call RInterface.StopRServer end sub but I get an error : "unsupported data when trying to execute "passTestb1" I also tried: Dim x As StatConnector Set x = New StatConnector MsgBox ("Initializing R...") x.Init ("R") x.EvaluateNoReturn ("F11b1<-read.table(""c:/test/Testb1.txt"", _ header=TRUE)") .. but then I don't known how to end Have you an idea to help me? Thanks, Nolwenn ---------------------------------------------------------------------- NetCourrier, votre bureau virtuel sur Internet : Mail, Agenda, Clubs, Toolbar... Web/Wap : www.netcourrier.com T?l?phone/Fax : 08 92 69 00 21 (0,34 E TTC/min - 2,21 F TTC/min) Minitel: 3615 NETCOURRIER (0,15 E TTC/min - 1,00 F TTC/min) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
i cannot diagnose you problem completely because i do not know what kind or result your function pass returns and therefore what kind of object passTestb1 is. the current version of my vba interface needs matrices. if your result is not a matrix, but "compatible" with the matrix type, then Call RInterface.getArray("as.matrix(passTestb1)", Range("D2")) should work. Call RInterface.RRun("passTestb1") is definitely a bbad idea except when pass created a function as its return value. nolwennlm at netcourrier.com wrote:> Hi, > I'm trying to combine a VBA macro and a R package. I've installed the R-(D)COM and the R-excel interface by Neuwirth. They seem to work both. However I would like to display the r-generated data in an Excel sheet as an array but I don't manage. > > Here is an example of my source: > Sub doR() > Call RInterface.StartRServer > Call RInterface.RRun("library(mdnn)") > Call RInterface.RRun("F11b1<-read.table(""c:/test/Testb1.txt"", header=TRUE)") > Call RInterface.RRun("passTestb1<-pass(Testb1, Threshold=5, ExtremeThreshold=5)") > Call RInterface.RRun("passTestb1") > Call RInterface.getArray("passTestb1", Range("D2")) > Call RInterface.StopRServer> end sub >-- -- Erich Neuwirth, Computer Supported Didactics Working Group Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-38624 Fax: +43-1-4277-9386 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
what happens when you remoove the line i indicate? and: the matrix you are reading in is NOT what you try to get with Call RInterface.getArray("passTestb1", Range("D2")) you APPLY the function pass to the matrix you read in. i need to know what kind of object pass returns to be able to diagnose. can you tell me what return value pass produces, or send me the definition of pass?> Sub doR() > Call RInterface.StartRServer > Call RInterface.RRun("library(mdnn)") > Call RInterface.RRun("F11b1<-read.table(""c:/test/Testb1.txt"", header=TRUE)") > Call RInterface.RRun("passTestb1<-pass(Testb1, Threshold=5, ExtremeThreshold=5)")----------------> Call RInterface.RRun("passTestb1")> Call RInterface.getArray("passTestb1", Range("D2")) > Call RInterface.StopRServer > end sub >-- Erich Neuwirth, Computer Supported Didactics Working Group Visit our SunSITE at http://sunsite.univie.ac.at Phone: +43-1-4277-38624 Fax: +43-1-4277-9386 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._