我正在绘制每个主题对两个块(A 块和 B 块)中“相同”或“不同”刺激的反应比例,这意味着每个主题都绘制了 4 个数据点。两个用于 A 块(相同和不同),两个用于 B 块(相同和不同)。也意味着有 4 行数据包含每个主题的响应比例。
我想将每个主题的“相同”和“不同”数据点与块内的一条线连接起来(例如,“相同”的数据点和“不同”的数据点通过 A 块内和 B 块内的线连接每个主题的块)。
我尝试使用 geom_line() 附带的“group = subject”,但是当我只想连接每个块内的数据点时,它会连接所有主题的数据点。
testplot <- ggplot(df, aes(x=block, y=prop, shape=con, colour=con)) +
geom_point(position=position_dodge(width=.1)) +
xlab("Block") + ylab("Prop of responses") +
theme_bw(base_size = 13) +
theme(legend.position="top")
plot(testplot)
Run Code Online (Sandbox Code Playgroud)
样本数据集:
subj = c(1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4)
prop = c(0.5, 0.8, 0.3, 0.7, 0.9, 0.4, 0.1, 0.5, 1, 0.5, 0.9, 0.2, 0.7, 0.4, 0.8, …Run Code Online (Sandbox Code Playgroud)