Reputation: 41
Simply put, I want to make a C# front-end for an R project.
Ellaborating a bit: I want to use a function I define in an R project (RTVS) in my C# code using RDotNet, but extensive search in Google yielded no results (by the way, it seems that even the question is not asked, so I understand that I may be having a "you did not see the obvious" problem here... but, if so, I'm failing to see the obvious for hours!).
To be more specific:
rEngine.Evaluate("source('Script.R')");
in RFrontEnd to access the code I wrote in Script.RA few points:
rEngine.Evaluate("source('C:\<Project Address Here>\Script.R')");
, but that makes my project dependent on the specific location of the R file in the file system. I know I can make this location a parameter I could place in a config file, but there must be a more elegant, built-in solution... right?source('Script.R')
and my functions are loaded normallyVersion specifications:
Can anyone please help me with that?
Thanks and cheers!
Upvotes: 0
Views: 459
Reputation: 41
It just came to me that you can link files to a project, so I can place links to my .R files in my C# project and have them copied to a folder in the project's output.
This is done by dragging the .R files from the R project with the Alt key pressed and dropping them somewhere in my C# project (preferentially in a properly named project folder) and then going to the newly linked .R file's properties and setting it to be copied to the project's output (this is absolutely essential, as a link is not a true file and will not be on the expected file system folder when the project is built, unless the file is marked to be copied on build).
This is not the elegant solution I have expected, but it does get my .R files to a known, fixed location, even if I have to deploy my project somewhere else, so I can do something like rEngine.Evaluate("source('R Scripts/Script.R')");
and get my functions properly set to run in the R environment (via RDotNet), inside my C# code, while still being able to properly edit them in an R project, with all the language support found there.
Still, if there is a better solution in someone's knowledge, please bring it!
Upvotes: 1