Executing Wolframscript Code in Rstudio Through Terminal

I am interested in using Wolframscript to perform certain operations in R but am a bit new to programming at a level beyond data analytics.

It is rather easy to start a terminal running wolframscript:

rstudioapi::terminalExecute("wolframscript")

will open it in a terminal tab. Indeed, one can also run lines of code via CTRL+ALT+ENTER. My question, then, is how would one attempt to run commands toward the mathematica terminal and retrieve results thereafter?

My main goal is to create some loop to send code and receive output- here's an example of the general idea:

X <- rweibull(100,1.5)
A <- vector(length=100)
for (a in 1:length(A)){
    send_code_to_Wolfram(Integrate[(E^(TX[a]u))*(E^(Bu)),{u,0,X[a]}])
    A[a]<-Output_from_wolfram }

Where T and B are matrices, send_code_to_Wolfram and Output_from_wolfram are undefined functions. Here, the obvious use of wolframscript would be to utilize its numerical integration and matrix exponentiation capabilities which are mostly unavailable in R.

Would anyone know how this might be possible to implement?
It seems that I can send code via naming the terminal and then using the TerminalSend command, though it does not submit (it merely enters it into the input line)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.