Problem referencing previous responses in a run

36 views
Skip to first unread message

Paul Lefebvre

unread,
Mar 22, 2022, 12:10:02 PM3/22/22
to formr

Hi all,

Apologies if this has come up before, but I can't find any information on it. I am setting up an ESM study in which participants will respond to 5 short surveys at random times (plus minimum spaces) throughout the day (9am to 6pm). At each of those 5 surveys participants report on whether they have experienced a particular kind of event. If they report any of these events across the 5 surveys, they are sent a follow-up "end of day" survey which asks them for more detail about the 1 or more events they reported that day. Below is an overview of the relevant portion of the run:

... Some intake stuff here

26 Pause for daily survey (references random survey timings generated earlier in the run)

30 Email reminder for daily survey

31 SMS reminder for daily survey

40 Daily survey

50 Loop back if less than 5 daily surveys sent today

60 Pause until 7pm

70 Skip forward to 100 if no events reported today

80 Email reminder for End of Day survey

90 End of Day survey

100 Skip back to 26 if less than required # days have passed

... Some end of run stuff here

This is all working (more or less) as I intend it to, but I am having an issue referencing participant descriptions of the daily events in the End of Day survey. Specifically, the problem comes up when participants do not respond to one of the daily surveys. My first thought was to use the following code in the End of Day survey to reference the possible event descriptions for each of the fives daily surveys that day:

tail(multi_daily_survey$event_description, n =5)[1]

tail(multi_daily_survey$event_description, n =5)[5]

This works just fine when participants have opened each of the 5 daily survey links, but if participants have not opened one of the links I run into problems. It seems that no new row is created in “multi_daily_survey” if the participant does not ever open the link (even if that survey expired). So, when I try to reference the event description from the daily surveys, I am not getting what I expect unless all the daily survey links for that day have been accessed by the participant (e.g., when I try to reference daily survey #3, I get #4 if one earlier survey was never responded to).

I have been able to get around this issue for timing the pauses before each loop through the daily survey using some insight from another post in the FormR group to count the number of daily surveys which have been created (regardless of whether they were ever accessed) with the following:

survey_unit_sessions[survey_unit_sessions$position == 40,]$created)

But I am struggling to figure out how to solve this problem when it comes to referencing the actual responses to survey items. Should I be creating separate positions in the run and separate surveys for each of the 5 instances of the daily survey I want to send out (rather than looping over the same thing 5 times)? That feels horribly inelegant, but I haven’t been able to think of another idea that might solve my problem. I’m still a relative R and formr beginner though, so I’m hoping one of you kind people has an idea that could help. Any thoughts would be really appreciated!

Thanks,

Paul

Reply all
Reply to author
Forward
0 new messages