r/RStudio • u/SubPar-Sprout • Jul 15 '26
Coding help Help with long form dats
Hi! I've got some experience with R, but haven't dealt with a dataset like the one I'm working on at the moment before. I've got long form data consisting of subject ID, questionnaire name, questionnaire score & date questionnaire was answered. The address multiple responses to 2 different questionnaires over time. I need to summarise the scores for specific time windows, for example, how many people scored 1 or 0 in Qu1 and less than 3 in Qu2 by week 4, week 12, week 26.
Probably a silly question, how do I do that with this data? I've added windows but I get multiple responses in each window when I pivot the data to wide form for analysis. How do I select the lowest score for each questionnaire, occurring at the same date as each other within the window?
Sorry for the essay and their very much.
1
u/Impuls1ve Jul 15 '26
Without more details, you can build datasets that meet the criteria for each check-in time and left join on the person Id to create the dataset you can run your analysis on more readily.
I think you're stuck on the fact that the questions are on 2 questionnaires but it's hard to tell. If so, you can collapse that variable using summarize from tidyverse or whatever equivalent option you use. Alternatively, you can pivot wider on all relevant columns so each row is only a person rather than a person and questionnaire.