Possible to run R code in JATOS session?
I'm new to JATOS so I apologize for the novice question. I'm looking to create a survey. I'd like the session to administer the survey to the participant and provide live scoring. The scoring would be performed by R code. I can do this with Shiny (https://shiny.rstudio.com/), but was wondering whether running R code is possible in a JATOS session (without running a separate server).
This is similar to the question here (https://forum.cogsci.nl/discussion/6538/r-script-after-jatos). In that thread, it was noted that a separate R server would need to be set up. I'd rather not set up a separate server. Is it possible to run R code in a JATOS session without a separate R server? If not, are there services that you'd recommend instead of JATOS? Thanks in advance!
Comments
Hi,
R shiny creates an HTML file in the end, so you wouldn't be reading R on the browser, but HTML/JS. So it might be possible. As far as I know, shiny apps expect a "shiny server", so there must be some functions that are posting data to the server that we should be able to replace with jatos.js functions.
I tried with the example app and I'm not entirely sure where to look. Would you be able to share a minimum example of your R code (or better, Rproj) so that we can look into it?
Best
Elisa
Hi Elisa,
Thanks for your response. Here's some example code of a basic Shiny app (from here: https://mastering-shiny.org/basic-app.html):
library(shiny) ui <- fluidPage( "Hello, world!" ) server <- function(input, output, session) { } shinyApp(ui, server)This would be saved in a file called app.R. I'll be interested to know whether this will work in JATOS--thanks!
Thanks, but I wanted to see something more complex than the hello world example, or the default shiny app when one creates a project. This will let me see how a proper survey with many questions looks like and I will know better where to include all the functions to communicate with JATOS.
Could you send me something closer to what you're trying to use? I'll have a look. If you prefer not to share it, I'll try it with the default shiny app
Hi Elisa,
Thanks for clarifying. I appreciate the request---however, I haven't created the survey yet. To find something it may eventually be similar to, see here:
The GitHub code is here:
Also, in case it's helpful, here's an article that discusses how to use Shiny for creating surveys (and it has a GitHub page linked with examples):
Thanks,
Isaac