如何使R中的纵向数据制作预期值曲线

发布于 2025-01-23 22:39:44 字数 55 浏览 3 评论 0原文

我有一个纵向数据,我想在其中制作预期价值曲线。在X轴上,我有时间,在y轴上,我有一个连续的变量。

I have a longitudinal data where I would like to make the expected value curve. In the x-axis I have time and in the y-axis I have a continuous variable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖不如嘢 2025-01-30 22:39:44

没有数据,首先很难重现您的问题,我生成了一些随机数据:

df <- data.frame(Age = sample(1:50),
                 variable = runif(50, 0, 1))

我不确定这是否是您想要的,但是您可以使用此代码使用geom_smooth来创建一个预期值曲线

library(tidyverse)
df %>%
  ggplot(aes(x = Age, y = variable)) +
  geom_point() +
  geom_smooth()

: :

Without data it is hard to reproduce your problem first I generated some random data:

df <- data.frame(Age = sample(1:50),
                 variable = runif(50, 0, 1))

I am not sure if this is what you want, but you can use geom_smooth to create an expected value curve using this code:

library(tidyverse)
df %>%
  ggplot(aes(x = Age, y = variable)) +
  geom_point() +
  geom_smooth()

Output:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文