dat <- structure(list(Participant_ID = c("A", "A", "A", "A", "B", "B",
"B", "B", "C", "C", "C", "C"), phase = structure(c(1L, 2L, 3L,
4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c("base", "sixmos",
"twelvemos", "eighteenmos"), class = "factor"), result = c("Negative",
"Negative", "Negative", "Negative", "Negative", "Positive", "Negative",
NA, "Positive", "Indeterminate", "Negative", "Negative")), .Names = c("Participant_ID",
"phase", "result"), row.names = c(1L, 2L, 3L, 4L, 97L, 98L, 99L,
100L, 9L, 10L, 11L, 12L), class = c("cast_df", "data.frame"))
看起来像:
Participant_ID phase result
1 A base Negative
2 A sixmos Negative
3 A twelvemos Negative
4 A eighteenmos Negative
97 B base Negative
98 B sixmos Positive
99 B twelvemos Negative
100 B eighteenmos <NA>
9 C base Positive
10 C sixmos Indeterminate
11 C twelvemos Negative
12 C eighteenmos Negative
我想为每个测试添加一个标识符,以说明该测试是从以前的状态(从负到正)的转换,还是恢复(从正到负)或稳定。问题是,我不仅仅是比较基础测试和六个月测试,六个月到十二个月,等等-在像C这样的情况下,六个月测试应该被标记为稳定或不确定(确切的术语是不明确的),而且(更重要的是)十二个月测试应该和基础测试进行比较,并被标记为回归。相反,如果某人有一系列的“否定”、“不确定”、“否定”,那应该是稳定的。
这是后一部分,我被困在;如果只是对每个参与者进行一系列的比较,我会没事的,但我在思考如何优雅地处理这些可变的比较对时遇到了困难。一如既往,我们非常感谢你的帮助。