I have a vb.net program which processes some data and user input and then uses R.net to set this information into R objects and run R scripts on these objects.
My problem is that this is hard for me to debug, as the error messages that bubble back up through the Visual Studio debugger about the R scripts are often not helpful.
My latest solution to this is to add
engine.Evaluate("save.image('Scripts/debugging/image.RData')")
into my vb.net code just before the script that has an error. This allows me to load up the objects in my R IDE and check if everything is in the form I expect it to be.
I was wondering if there was a better way to do this? For instance I wonder is it possible to set up the R environment/engine to run a save.image() if an error is encountered automatically?
Related
I am new to R and Rstudio and currently trying to figure out a few things that would easen switching too much between the linux-terminal and the file navigating system. As I prefer using the former I would therefore like a method that allows me to open .R files in R studios in-built editor but directly via the linux terminal. I have tried to illustrate what I want on the attached picture. Does this functionality exist? So far I have only been able to execute R scripts via the terminal.
I have trawled through the web trying to find a similar question but they all seem to be related to executing R scripts via the terminal rather than opening them in the Rstudio editor.
I want to execute a R script every time an azure function is triggered. The R script executes perfectly on Azure machine learning Studio. But I am failing to execute through azure function.
Is there any way to execute it?
AFAIK you'll have to create your own Runtime as R isn't supported natively.
Have you already tried "Create a function on Linux using a custom container"? Interestingly they have given R as the example of custom runtime, so hopefully that answers your question.
I am trying to integrate R into an Azure Function.
Instead of just calling the R exe - I want to be able to try the R.NET library to make it easier to pass and collect data between .NET and R. For example, respond to an event.
It runs fine locally, but once deployed as an Azure function, I get various errors. The latest ": This engine is not running. You may have forgotten to call Initialize"
For anyone else wanting to try this, I had to force the Azure function to run as 64bit, and also install the R extension library to the function. at RDotNet.REngine.CheckEngineIsRunning()
Has anyone had any success? Is anyone with R.NET experience wanting to help getting to work as an Azure function environment?
Looking at the code in R.NET for the functions RDotNet.REngine.GetInstance(), RDotNet.REngine.CheckEngineIsRunning(), and RDotNet.REngine.Initialize(), it appears as though creating the engine instance via RDotNet.REngine.GetInstance() should help you avoid this issue, as after calling that the method should be running, and you should not be encountering this area.
It is possible that you are encountering some error in creating this instance. Looking at the code comments about usage in the above link, it looks like an environment variable needs to be set for PATH. It is possible that the code you used to set this up does not work in Azure Functions. You can manually set environment variables in Azure Functions by using App Settings.
I am executing an R script as ms-sql stored procedure. I'm trying to use the "geosphere" package, however when I execute the stored procedure, I'm getting the error "Invalid BXL stream" and the execution halts. The package is already installed on the machine and simply loading the package causes this error i.e library("geosphere") causes the error.
I can however, use this package independently with R Studio, so there doesn't seem to be any issue with the package.
I know this question is dated but I've run into the same issue multiple times so I wanted to leave my results here.
What I've found in using sp_execute_external_script to run R and Python scripts in MS-SQL 2016/17 is that the BXL error comes for 2 different reasons
Bad data types - Often, SQL doesn't understand the data types being sent out of the script. Usually explicitly casting the data as a certain datatype helps here.
Bad package configuration - Certain packages in the R and Anaconda distributions don't sync well with the stored procedure since the database blocks certain dependencies in these packages. Try reinstalling the package in the SQL installed instance of R or Python.
It seems that your problem falls in the latter category. I hope that helped!
Had a similar issue today but with a different package. Getting "invalid BXL stream from MSSQL stored procedure. However, i found that If i opened up Rterm.exe and typed the command 'require(packagename)' then Rterm crashes with "Rterm frontend has stopped working". This looks like a memory issue - which has also been suggested causes the "invalid BXL stream" error.
However, my issue turned out to be the fact that the dependencies for the packages had not been installed correctly (perhaps you are working through a proxy?).
I basically removed all the library packages that had been created when I first installed the problem package and did a install.packages("packagename"). All started working!
Apologies - just noticed that you stated that the package worked independently with R studio - this is probably an issue with R Memory allocation with SQL - See http://henkvandervalk.com/introducing-microsoft-sql-server-2016-r-services
I just ran this in RStudio and it works fine.
Gender <- c("Female","Female","Male","Male")
Restaurant <- c("Yes","No","Yes","No")
Count <- c(220, 780, 400, 600)
DiningSurvey <- data.frame(Gender, Restaurant, Count)
DiningSurvey
Then I try to run it in Visual Studio and it does nothing at all.
If I go to Test > Run > All Tests, I get this: 'There were successful build errors. Would you like to continue and run tests from the last successful build?' There is no last build and no matter what I try, this doesn't work. IF I hit any function key, including F5, F11, or whatever, this doesn't work!! How can I run R code in Visual Studio? It seems like this should be super-simple, but it is very, very, very difficult.
Thanks.
In general, R in VS works same a R in RStudio. In other words, F5 does not work since R is not a compiled language and does not have predefined entry point. For example, for debugging you set a breakpoint, then attach debugger, then source file and then call the desired function from R interactive window.
To run R in Visual Studio, you need the R Tools for Visual Studio (RTVS) plugin.
You can download this at http://microsoft.github.io/RTVS-docs/
This will turn Visual Studio into a capable client that knows how to deal with R.
Once you've installed RTVS, the easiest way to get started is to create a new R project:
\File\New\Project...\New R Project
This will create a new project with templates for R and Rmd files.
You can send code from an R file to the "R Interactive" window by pressing Ctrl+Enter.
You can see this in action by watching the video at https://youtu.be/KPS0ytrt9SA