[R] Calling a source file from R to C#

Duncan Murdoch murdoch.duncan at gmail.com
Sat Mar 15 12:46:29 CET 2014


R 2.11.1 is really old, but that's not likely to be your problem.  I'd 
guess that file n1.R doesn't contain what you think it contains.  If you 
run the source() command from within R, does that work?

Duncan Murdoch

On 14-03-15 3:18 AM, Ashis Deb wrote:
> I had this code like :--
>
>
> using System.Text;
> using RDotNet;
> using RDotNet.NativeLibrary;
> using Stats;
>
>
> namespace ConsoleApplication1
> {
>
>      class Program
>      {
>          static void Main(string[] args)
>          {
>
>
>              string rhome =
> System.Environment.GetEnvironmentVariable("R_HOME");
>              if (string.IsNullOrEmpty(rhome))
>                  rhome = @"C:\Program Files (x86)\R\R-2.11.1";
>
>              System.Environment.SetEnvironmentVariable("R_HOME", rhome);
>              System.Environment.SetEnvironmentVariable("PATH",
> System.Environment.GetEnvironmentVariable("PATH") + ";" + rhome +
> @"\bin\i386");
>
>              REngine.SetDllDirectory(@"C:\Program Files
> (x86)\R\R-2.11.1\bin");
>
>              using (REngine engine = REngine.CreateInstance("RDotNet"))
>              {
>
>                    engine.Initialize();
>
>                    REngine R = REngine.GetInstanceFromID("RDotNet");
>
>                    engine.Evaluate("source('D:/n1.R')");   <<-------  here
> i  m  calling  a  r script   contain  a  function  .
>
>
>                  Console.ReadKey();
>
>              }
>          }
>      }
> }
>
>
>
>
>
>
>
>
> My  function  looks like :---
>
>
>
>
> fun<-function(x,y)
> {
>
> z=x*y
>
> return(z)
>
> }
>
>
>
>
> But  i  getting  the  error like  :-   Parse exception  was  unhanded  &
> in the  command  line its showing like :----
>
> Error in source :-<"D:/n1.R") : D:/n1.R:1:1: unexpected ')'  1: )
>
>
>
>
> I  am  using  R 2.11.1  and  vs2010 .
>
>
>
> Does anybody  have any  solution for this ??  ,please help me out with
> this  issue.
>
>
>
>
>
> PS :-  ashis deb
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list