简体   繁体   English

如何在 plot 中绘制带有重复测量变量和连续变量的散点图 r?

[英]How do I plot a scatterplot graph with a repeated-measures variable and a continuous variable in r?

I have a four levels repeated measures variable (let's call it RM) and I have a continuous variable predictor (let's call it C).我有一个四级重复测量变量(我们称之为 RM),我有一个连续变量预测器(我们称之为 C)。 I want to plot a scatterplot graph with C on the X-Axis and RM on the Y-Axis with different lines within the plot for each level of RM.我想要 plot 散点图,X 轴为 C,Y 轴为 RM,每个 RM 级别在 plot 内有不同的线。 Is this possible to do with ggplot or a similar package?这可能与 ggplot 或类似的 package 有关吗? Thanks in advance!提前致谢!

Utilizing ggplot2, you should be able to achieve this type of graphical output. Viewing a portion of your data that you wish to plot would be beneficial to provide a sufficient answer.使用 ggplot2,您应该能够实现这种图形 output。查看您希望 plot 的部分数据将有助于提供充分的答案。

I have attached a link to a summary of ggplot2 graphical functions here .在此处附上了 ggplot2 图形函数摘要的链接。 This link provides some background on ggplot2 and the components necessary to create a graph.此链接提供有关 ggplot2 的一些背景知识以及创建图形所需的组件。 Three components are needed in ggplot2 to make a graph, the data, the ggplot2 function, and mapping your variables with the aesthetic. ggplot2 中需要三个组件来制作图表、数据、ggplot2 function 以及将您的变量与美学进行映射。

Because you don't have a representation of some of your data, providing a sufficient answer is difficult, but it might look something like this.因为您没有一些数据的表示,所以很难提供足够的答案,但它可能看起来像这样。

ggplot(data=yourdata, aes(x= C(continuous_variable, y = RM(repeated_measures)) + geom_point() ggplot(data=yourdata, aes(x= C(continuous_variable, y = RM(repeated_measures)) + geom_point()

You may also map geom_line for each RM variable in addition to this example.除了此示例之外,您还可以为每个 RM 变量使用 map geom_line。 Hope this helps!希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM