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)
。