为这个尴尬的标题道歉;我希望这一点很快就会明朗化。
我有这样的数据:人员被分配到特定的地点,并记录事件是否成功或数据是否缺失。
df <- data.frame(PersonID = c(1:20),
Location = c("B","A","D","C","A","D","C","D","A","D","B","A","D","C","A","D","C","D","A","D"),
Success = c("yes","no","yes",NA,"yes","no","no","yes",NA,"yes","no","yes",NA,"yes","no","no","yes",NA,"yes","no"))
我想知道每个位置相对于其他位置的"表现"如何,即有多少有效的尝试已经成功,以及该位置的成功率与其他位置相比如何。
因此,在我的示例中,地点"A"经历了5次有效尝试(1次"NA"),其中3次成功(60%)。其他地点的成功率分别为50%、66.7%和50%,平均值为55.6%。因此,地点A比其他地点的平均值高4.4个百分点。我希望在如下表中显示所有这些信息:
我对软件包没有特别的偏好,但是我喜欢并且知道一些gt
和flextable
。
提前感谢大家!
2条答案
按热度按时间41zrol4v1#
这在任何方面都不是微不足道的:
oyxsuwqo2#
来自@TarJae的回答很好,类似的方法与下面的flextable。