hidden sampling doesn't always work

12 views
Skip to first unread message

Richard Wundrack

unread,
Jan 15, 2024, 11:06:33 AMJan 15
to formr
Hi there,
I use the "hidden" type in a survey to randomly sample – sample(c(0,1),1,replace=T) – whether an item is displayed one way or another, i.e. the sampling affects the "showif" column. However, it happens fairly regularly during testing that the hidden command just does not save a specific value which leads my showif logic to crash due to the missing value. Has this happened to others?  What could be the problem? How can I solve this? In the attached screenshot you can see two variables "range_start" and "range_reverse" for which a hidden sample()-function quite often not save a value...

Thanks for the help!
Screenshot 2024-01-15 at 17.04.30.png

Ruben Arslan

unread,
Jan 16, 2024, 3:58:08 AMJan 16
to Richard Wundrack, formr
Hi all,

As far as I can tell from the description, nothing is crashing. Just the conversion of numbers to text that happens when you don't explicitly tell R it's text is counter-intuitive, it
converts 0 to an empty string "".

sample(c("0","1"),1,replace=T)
should do the trick, or explicitly converting with as.character, or using 1 and 2 instead of 0 and 1.

Best wishes,

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/424cb879-934f-4fc4-9193-08231d54e3a7n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages