R 如何在ggplot的散点图中绘制成对数据?

R 如何在ggplot的散点图中绘制成对数据?,r,ggplot2,scatter-plot,R,Ggplot2,Scatter Plot,我有一个数据框,它包含来自同一受试者的不同时间点时间0和时间3的成对样本。如何为每个对象生成x坐标对应于时间0、y坐标对应于时间3的散点图 subject = c(1,1,2,2,3,3) time = c(0,3,0,3,0,3) dependent_variable = c(1,5,4,12,3,9) df = data.frame(subject, time, dependent_variable) 为了达到您想要的结果,您可以使用tidy::pivot\u等工具对数据进行重塑: 主题=

我有一个数据框,它包含来自同一受试者的不同时间点时间0和时间3的成对样本。如何为每个对象生成x坐标对应于时间0、y坐标对应于时间3的散点图

subject = c(1,1,2,2,3,3)
time = c(0,3,0,3,0,3)
dependent_variable = c(1,5,4,12,3,9)
df = data.frame(subject, time, dependent_variable)

为了达到您想要的结果,您可以使用tidy::pivot\u等工具对数据进行重塑:

主题=c1,1,2,2,3,3 时间=c0,3,0,3,0,3 因变量=c1,5,4,12,3,9 df=data.framesubject,时间,因变量 图书馆GGPLOT2 图书馆三年 df_宽% pivot\u widernames\u from=时间,values\u from=依赖变量,names\u prefix=时间 ggplotdf_宽,aestime0,time3,颜色=因子主体+ 几何点
为了达到您想要的结果,您可以使用tidy::pivot\u等工具对数据进行重塑:

主题=c1,1,2,2,3,3 时间=c0,3,0,3,0,3 因变量=c1,5,4,12,3,9 df=data.framesubject,时间,因变量 图书馆GGPLOT2 图书馆三年 df_宽% pivot\u widernames\u from=时间,values\u from=依赖变量,names\u prefix=时间 ggplotdf_宽,aestime0,time3,颜色=因子主体+ 几何点
向上投票+1,在使用ggplot2时,看到一位教授其他人重新绘制数据的重要性的帖子总是很棒!向上投票+1,在使用ggplot2时,看到一位教授其他人重新绘制数据的重要性的帖子总是很棒!