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.
Related
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 using learnr to build up in-class slides held by shiny.io. The codes I would like to show includes some calling an external API. The file is smoothly compiled and uploaded to shiny.io. However, when I ran the codes through the shiny server, I got an error stating that
Cannot visit /tmp/RtmplHHftl/ID_20180123212516_1458.html because the browseURL function is disabled.
I searched online and found only one relevant post from Rstudio connect stating that the problem can be solved by using functions like shiny::tags$a function without any instruction about where and how to insert such functions.
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?
Is it possible to insert a browser statement (or equivalent) in your R code with opencpu and when the ajax or plot call is made the R session (or Rstudio session) from which the opencpu server instance is running will stop and allow debugging?
No, I don't think that would make sense. The OpenCPU server exposes an HTTP API to call R functions. If you want to debug the R function, just call it locally in R. That way you an use all your usually debugging tools.
Once the function works as expected you can call it remotely through the OpenCPU API, and it will give the same result.
Perhaps you can give an example of the type of problem that you're trying to debug, maybe I can give some advice on your workflow.
Has anyone successfully used the Google Predication API from within R? My goal is to perform the following tasks:
Upload and manage the data in Google Storage
Use this data to train a model from Google Prediction
I have followed the install instructions located here and here (when using Windows). I have not been able to successfully connect using both Mac OSX and Windows.
I suspect that the core issue is authentication. There is scattered documentation and I feel like I have tried everything (even the overview of the R package designed for this purpose).
I am not the greatest programmer, but I can typically follow along with code and piece together what I need from worked examples. At this point, though, I simply do not know what else to try.
Many thanks in advance.
Marc Cohen seems to be right, I think something is broken. However I managed to pass authentication, here is how:
Download the googlepredictionapi_0.12.tar.gz and extract it inside a temporary folder. Then open googlepredictionapi/R/prediction_api_init.R inside an Editor and remove the lines
myEmail <- ""
myPassword <- ""
myAPIkey <- ""
Afterwards repackage the source files and load them in R:
tar czf googlepredictionapi.mod.tar.gz googlepredictionapi
R
remove.packages("googlepredictionapi")
Now you should be able to follow the steps in [1] http://code.google.com/p/r-google-prediction-api-v12/. However instead of calling
install.packages("googlepredictionapi_0.12.tar.gz", repos=NULL, type="source")
you need to call
install.packages("googlepredictionapi.mod.tar.gz", repos=NULL, type="source")
Following the steps, at some point a file $HOME/.auth-token should be generated.
(You can even explicitly trigger this by calling explicitely: PredictionApiUtilGetAuth(verbose=TRUE), myEmail and myPassword must be set beforehands.)
For some reason the global variables that are manually set in [1] have been shadowed by the removed lines above. The same is actually true for the verbose option which you can pass to most API function calls as extra option ..., verbose=TRUE).
Hope this helps.
Last I heard (April of this year), R support for the Google Prediction API was not yet upgraded to use OAuth so when the Prediction API switched from the older client login scheme to OAauth 2.0, it effectively broke R functionality.