Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 添加一条平滑的平均浓度线_R_Ggplot2_Smoothing - Fatal编程技术网

R 添加一条平滑的平均浓度线

R 添加一条平滑的平均浓度线,r,ggplot2,smoothing,R,Ggplot2,Smoothing,我试图在代码中添加一条平均大小的几何平滑线 ggplot(data = Birds, aes(Species, size, color=Subject)) + geom_line() + labs (x = "Species", y = "Size(cm)", title = "Size and Species of Birds") + theme_bw() 这就是你要找的吗

我试图在代码中添加一条平均大小的几何平滑线

ggplot(data = Birds, 
       aes(Species, size, color=Subject)) +
  geom_line() +
  labs (x = "Species",
        y = "Size(cm)",
        title = "Size and Species of Birds") +
  theme_bw()

这就是你要找的吗?将
color=Subject
添加到
aes
将为每个主题创建不同的行。因为每个受试者都接受了不同的剂量,但它们是在相同的时间间隔进行测量的,所以如果不根据受试者分割线,绘制geom_line()会产生一些奇怪的结果。换句话说,一个x值有多个y值

ggplot(data = Theoph, 
       aes(Time, conc)) +
  geom_smooth()+
  #geom_line() +
  geom_point() +
  labs (x = "Time after dose (hours)",
        y = "Theophylline oncentration (mg/L)",
        title = "Theophylline concentration in all subjects over time") +
  coord_equal() +
  theme_bw()

如果您只需要一条干净的平均线,可以在
ggplot
“管道”之外进行,然后绘制新的平均线。虽然我不知道,但是在
ggplot
中可能有一种方法可以完成这一切。

你能提供一些关于你想要什么的更多信息吗?有没有可以分享的例子?如果你想保留点的颜色,你可以做
geom_点(aes(color=Subject)