R 表示评分变量的最佳方式是什么?

R 表示评分变量的最佳方式是什么?,r,R,我得到的数据如下: Number Age Headache painful fatigue 1 43 5 2 3 1 45 3 3 3 1 46 6 5 2 2 66 1 0 3 2 67 1 4 5 2 68 4

我得到的数据如下:

Number  Age  Headache painful fatigue
1       43       5       2       3
1       45       3       3       3
1       46       6       5       2
2       66       1       0       3
2       67       1       4       5      
2       68       4       6       6
2       69       5       7       8

同一个数字指的是同一个人。头痛、疼痛和疲劳的得分从0到10。对于所有患者来说,哪种方法是可视化/呈现每个症状得分变化的最佳方法?(最好使用年龄参数)希望得出这样的结论,从平均年龄x到x_1,痛苦的分数在增加。

我不会尝试组合不同的Y标度(这会使图表混乱),所以我会将不同的反应变量放在各自的图中

将属于同一个人的观察结果分组是有意义的

您可以按照以下思路做一些事情:

library(tidyverse)
library(cowplot)

df = data.frame(
  cbind(Number = c(1,1,1,2,2,2,2), 
    Age = c(43,45,46,66,67,68,69),
    Headache = c(5,3,6,1,1,4,5),
    painful = c(2,3,5,0,4,6,7),
    fatigue = c(3,3,2,3,5,6,8))
  ) %>% 
  mutate(Number = factor(Number))

p1 <- df %>% 
  ggplot(aes(x = Age, y = Headache)) +
  geom_line() +
  geom_point() +
  facet_grid(cols = vars(Number), scales = "free_x") +
  theme_bw()

p2 <- df %>% 
  ggplot(aes(x = Age, y = painful)) +
  geom_line() +
  geom_point() +
  facet_grid(cols = vars(Number), scales = "free_x") +
  theme_bw()

p3 <- df %>% 
  ggplot(aes(x = Age, y = fatigue)) +
  geom_line() +
  geom_point() +
  facet_grid(cols = vars(Number), scales = "free_x") +
  theme_bw()

plot_grid(p1, p2, p3, ncol = 1)
库(tidyverse)
图书馆(cowplot)
df=data.frame(
cbind(数字=c(1,1,1,2,2,2),
年龄=c(43,45,46,66,67,68,69),
头痛=c(5,3,6,1,1,4,5),
疼痛=c(2,3,5,0,4,6,7),
疲劳=c(3,3,2,3,5,6,8))
) %>% 
变异(数=因子(数))
p1%
ggplot(不良事件(x=年龄,y=头痛))+
geom_线()+
几何点()+
刻面网格(cols=vars(数字),比例=“自由x”)+
主题_bw()
p2%
ggplot(不良事件(x=年龄,y=疼痛))+
geom_线()+
几何点()+
刻面网格(cols=vars(数字),比例=“自由x”)+
主题_bw()
p3%
ggplot(aes(x=年龄,y=疲劳))+
geom_线()+
几何点()+
刻面网格(cols=vars(数字),比例=“自由x”)+
主题_bw()
绘图网格(p1、p2、p3、ncol=1)

或者,如果有更多的案例,您可以这样做:

p1 <- df %>% 
  ggplot(aes(x = Age, y = Headache, group = Number, color = Number)) +
  geom_line() +
  geom_point() +
  scale_x_continuous(breaks = seq(40, 70, by = 5)) +
  theme_bw()

p2 <- df %>% 
  ggplot(aes(x = Age, y = painful, group = Number, color = Number)) +
  geom_line() +
  geom_point() +
  scale_x_continuous(breaks = seq(40, 70, by = 5)) +
  theme_bw()

p3 <- df %>% 
  ggplot(aes(x = Age, y = fatigue, group = Number, color = Number)) +
  geom_line() +
  geom_point() +
  scale_x_continuous(breaks = seq(40, 70, by = 5)) +
  theme_bw()

plot_grid(p1, p2, p3, ncol = 1)
p1%
ggplot(不良事件(x=年龄,y=头痛,组=数量,颜色=数量))+
geom_线()+
几何点()+
比例x连续(中断=顺序(40,70,按=5))+
主题_bw()
p2%
ggplot(不良事件(x=年龄,y=疼痛,组=数量,颜色=数量))+
geom_线()+
几何点()+
比例x连续(中断=顺序(40,70,按=5))+
主题_bw()
p3%
ggplot(aes(x=年龄,y=疲劳,组=数量,颜色=数量))+
geom_线()+
几何点()+
比例x连续(中断=顺序(40,70,按=5))+
主题_bw()
绘图网格(p1、p2、p3、ncol=1)

当你有更多的病人时,你可以使用方框图或密度曲线