绘制多条线的平均线

时间:2018-06-14 09:41:02

标签: r ggplot2 sum average

看起来我确定之前已经问到了这个问题,但是我已经打了另一面墙,我想在情节上绘制多条线上的平均线。经过几个小时的努力,我似乎​​无法做到这一点。我知道它看起来很懒,我很抱歉,但请在我的智慧结束时帮助一个兄弟。我想在所有实验线上绘制平均线。我尝试过使用rowMeans,并试图通过对我的数据进行分组来生成新的数据帧,但没有成功。请使用。 https://www.dropbox.com/s/m1ao29xaudksanf/e1.txt?dl=0 https://www.dropbox.com/s/q0sf3hew2pco73s/c1.txt?dl=0

cc1L3 <- read.table('./Colony 1 Location 3/c1.txt', header=TRUE)
ec1L3 <- read.table('./Colony 1 Location 3/e1.txt', header=TRUE)
Col1Loc3 <- ggplot()+
geom_smooth(data=ec1L3, aes(Time,Current1, colour= 'experimental1L3'))+
geom_smooth(data=ec1L3, aes(Time,Current2, colour= 'experimental1L3'))+
geom_smooth(data=ec1L3, aes(Time,Current3, colour= 'experimental1L3'))+
geom_smooth(data=ec1L3, aes(Time,Current4, colour= 'experimental1L3'))+
geom_smooth(data=ec1L3, aes(Time,Current5, colour= 'experimental1L3'))+
geom_smooth(data=ec1L3, aes(Time,Current6, colour= 'experimental1L3'))+
geom_smooth(data=ec1L3, aes(Time,Current7, colour= 'experimental1L3'))+
geom_smooth(data=ec1L3, aes(Time,Current8, colour= 'experimental1L3'))+
geom_smooth(data=ec1L3, aes(Time,Current9, colour= 'experimental1L3'))+
geom_smooth(data=ec1L3, aes(Time,Current10, colour= 'experimental1L3'))+
###############
geom_smooth(data=cc1L3, aes(Time,Current1, colour='control1L3'))+
geom_smooth(data=cc1L3, aes(Time,Current2, colour='control1L3'))+
geom_smooth(data=cc1L3, aes(Time,Current3, colour='control1L3'))+
geom_smooth(data=cc1L3, aes(Time,Current4, colour='control1L3'))+
geom_smooth(data=cc1L3, aes(Time,Current5, colour='control1L3'))+
geom_smooth(data=cc1L3, aes(Time,Current6, colour='control1L3'))+
geom_smooth(data=cc1L3, aes(Time,Current7, colour='control1L3'))+
geom_smooth(data=cc1L3, aes(Time,Current8, colour='control1L3'))+
geom_smooth(data=cc1L3, aes(Time,Current9, colour='control1L3'))+
geom_smooth(data=cc1L3, aes(Time,Current10, colour='control1L3'))

2 个答案:

答案 0 :(得分:0)

我不完全确定你追求的是什么,但也许你想要这样的东西:

cc1L3 <- read.table('https://www.dropbox.com/s/m1ao29xaudksanf/e1.txt?dl=1', header=TRUE)
ec1L3 <- read.table('https://www.dropbox.com/s/q0sf3hew2pco73s/c1.txt?dl=1', header=TRUE)

library(dplyr)

df <- bind_rows(
  control = gather(cc1L3, variable, value, -Time),
  experimental = gather(ec1L3, variable, value, -Time),
  .id = 'treatment'
)

ggplot(df, aes(Time, value, color = treatment)) +
  geom_smooth(aes(group = interaction(variable, treatment)), se = FALSE, size = 0.5) +
  geom_smooth(se = FALSE, size = 2)

重塑数据至关重要。

enter image description here

答案 1 :(得分:0)

如何单独计算$uri="xxxxxx.net"; $path= "D:\main.bundle.js" $content= Get-Content -Path $path | Select-String "this.ApiUrl = """ | foreach-object { $_ -replace "this.ApiUrl = """, "this.ApiUrl = ""$uri" } ( Get-Content $path).replace("this.ApiUrl = """,$content ) | Set-Content $path

mean()

我希望它有所帮助。干杯!