Best way to Run R Script and Have Result go to a FileMaker Text Field?

I created a simple test solution and tried using "SendEvent" to run an R Script, but that seems to open R to run it in the foreground. Not what I want.

What I want to do instead is "capture" the result and have the R function run in the background, invisibly, if possible.

For example, if I run the simplest R script (R < Hello.R),

sayHello <- function(){
print('hello')
}
sayHello()
[1] "hello"

I'd like to capture this output and put it into a FileMaker text field.

How would this best be done in FileMaker?

Thanks,

Can you pipe the output from R into a file? That could be imported or read in via the data file commands.

If you are using shiny you can point a web viewer at it.

That's a great idea and it works!

$ R < Hello.R > out.txt --no-save

Now, how do I get FileMaker to execute that command without R coming up in the foreground? If I can get that working, then importing the data with the data file commands will be easy.

Thanks @Malcolm!

What about using plumber to create a rest api of R, then you could insert url to get the result from R?

I had already implemented RServe (an R TCP server) with a REST front-end previously (totally free), but that implementation does not work well on Windows due to Windows' inability to parallelize R processes. Client is looking for something simpler.
Thanks for your suggestion, however. :slight_smile:

1 Like