I have a dataframe with patients that have answered twice in same questionnaire in couple of years. Now I need to calculate how many patient developed problem, how many improved and how many maintained having problems. The answers are in scale 1-6 where <3 is no problem, 3-4.75 is sometimes problem and >= 5 is problems.
I have merged these two dataframe to one and tried to calculate difference by coding dat5$noproblem = ((dat5$sleepProblems.x)<3)-((dat5$sleepProblems.y)<3) but I only get a dataframe there is zero and minus 1 and which dimension is NULL.
I tried do the same with diff((dat5$sleepProblems.x<3) - lag((dat5$sleepProblems.y<3))) but I still get just list of different values.
as mentioned in your thread on SO, please provide some more details of the data and much better at least a sample of the data. You can use the dput function to get your data in a shape ready to copy-paste.
If this is also cross-posted on SO, please link to your post here as well.
Please see our site policy about cross-posting. We ask that, if it can't be avoided, you at least link to the other post, and keep the thread updated if you have received a solution to avoid someone spending time answering a question that's already been resolved.