jflournoy / qualtrics

This package utilizes the Qualtrics API to interface with the Qualtrics survey system.
1 stars 3 forks source link

coding of PDS_F6 menstruation #2

Open theresacheng opened 6 years ago

theresacheng commented 6 years ago

Error in data.frame(adren.f2, gonad.f2) : arguments imply differing number of rows: 54, 53

I think that the problem is that the scoring can't handle different codings of menstruation (there is exactly one participant who has not started menstruating in this sample, ergo the 54 to 53 nrow discrepancy). When I filter out the one subject, the script works.

I think the problem is related to the 1 or 4 coding from TDS qualtrics, which is then transformed to 1 to 5 line 128: menstruate.f <- c(1, NA, NA, 5)[menstruate]. In the study I'm trying to use the package with, not having started is coded as a 0, while having started is coded as 1. I copied and edited a version of the script where line 128 is replaced with menstruate.f <- c(1, 5)[menstruate], which I thought might do the trick, but maybe I don't actually understand this at all.

Also, I am realizing that I don't have a good handle on how to debug long functions.

jflournoy commented 6 years ago

Yeah, the PDS scoring is not done in a very modular way so it is hard to debug. If you can provide a data frame with just a single fake participant data that will cause the error, that would be really helpful. If I understand your case correctly, what in TDS would be either 1 or 4 is now 0 or 1 (and then in my script, it transforms the 1 or 4 into a 1 or 5 using a very hackish method). So you could transform your data for that question before sending it to the script.

theresacheng commented 6 years ago

actually, transforming the data up front resolves the issue. i added this requirement in the readme. would you still like some toy data to see the problem?

thanks!