Julio Marco A. Silva
Julio Marco A. Silva

Reputation: 41

How to acess an R project (RTVS) from a C# project in VS 2017 with RDotNet?

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:

A few points:

Version specifications:

Can anyone please help me with that?

Thanks and cheers!

Upvotes: 0

Views: 459

Answers (1)

Julio Marco A. Silva
Julio Marco A. Silva

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

Related Questions