Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Appreciate help with "Show If" conditions in formr survey

35 views
Skip to first unread message

Raphaela

unread,
Dec 20, 2023, 11:11:52 AM12/20/23
to formr

We are currently working on a survey using the `formr`, and we're having trouble with the conditional display of questions based on user responses.

I would like to implement a "show if" condition where a follow-up question will only be displayed if the user has clicked "yes" to a previous question.

However, the conditional display doesn't work as expected and I get an error code related to CPU usage.

“There was a problem evaluating showifs using openCPU”

(function() {

                library(formr)

                Study_1_SIB = as.data.frame(jsonlite::fromJSON("{\"studium\":[null],\"studienart\":[null],\"taetigkeit\":[null],\"taetigkeitsart\":[null],\"fachsemester\":[null],\"studienfach\":[null]}"), stringsAsFactors=F)

 

                (function() {with(tail(Study_1_SIB, 1), {

formr.showifs = list();

within(formr.showifs,  {

si.studienfach = (function(){

                studium == ja

})()

si.studienart = (function(){

                studium == ja

})()

si.fachsemester = (function(){

                studium == ja

})()

si.taetigkeitsart = (function(){

                taetigkeit == ja

})()

})

})})()

 

})()

Questions:

1.       How can I set up the Show If conditions correctly so that the next question is only displayed if the user chooses "yes"?

2.       Also, how can I examine the data or file being sent to the system during this process?

3.       What’s the best way to introduce a timed delay for the appearance of the "Continue" button in formr ?

Any insight or suggestions would be greatly appreciated.
Thanks in advance!

Errorcode_1.png

Ruben Arslan

unread,
Dec 20, 2023, 11:21:13 AM12/20/23
to Raphaela, formr
Hi Raphaela,

This is just an R error, not specific to formr. 
Your code syntax is invalid, which you'll see as well if you run the code in RStudio. If you're new to R, I can recommend pair programming with ChatGPT.
In this case, ChatGPT gives the correct hint, you are using "ja" as if it's a variable, but probably you want to refer to the string "ja"
or whatever number is encoded when people check "ja" in your survey (I can't see that from here.

Best,

Ruben


--
You received this message because you are subscribed to the Google Groups "formr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to formr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/formr/3511120a-cefd-499b-adf2-de1978704290n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages