相关疑难解决方法(0)

连接抖动点的线 - 多组躲避

我尝试在 x 轴上连接来自两种不同方法 ( measure ) 的测量值之间的抖动点。这些测量值通过先证者 ( a )相互关联,先证者可以分为两个主要组,患者 ( pat ) 和对照 ( ctr ),我的 df 是这样的:

set.seed(1)
df <- data.frame(a = rep(paste0("id", "_", 1:20), each = 2),
                 value = sample(1:10, 40, rep = TRUE),
                 measure = rep(c("a", "b"), 20), group = rep(c("pat", "ctr"), each = 2,10))
Run Code Online (Sandbox Code Playgroud)

我试过

library(ggplot2)
ggplot(df,aes(measure, value, fill = group)) + 
  geom_point(position = position_jitterdodge(jitter.width = 0.1, jitter.height = 0.1,
                                             dodge.width = 0.75), shape = 1) +
  geom_line(aes(group = a), position = position_dodge(0.75))
Run Code Online (Sandbox Code Playgroud)

reprex …

r ggplot2 jitter

2
推荐指数
1
解决办法
1385
查看次数

标签 统计

ggplot2 ×1

jitter ×1

r ×1