【发布时间】:2019-01-13 22:16:58
【问题描述】:
我们有一些整洁的数据,包括处理(多个样本和对照)、时间点和测量值。我想通过除以控制变量中的相应时间点来标准化所有样本。
我知道如何对自己列中的每个值执行此操作,但无法弄清楚如何将gather mutate、sumamrise 等从tidyr 或dplyr 组合到以直接的方式做到这一点。
这是一个示例数据框定义:
structure(list(time = c(1, 2, 3, 1, 2, 3, 1, 2, 3),
value = c(10, 20, 15, 100, 210, 180, 110, 180, 140),
as.factor.treat. = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L),
.Label = c("c", "t1", "t2"), class = "factor")),
.Names = c("time", "value", "treat"),
row.names = c(NA, -9L), class = "data.frame")
数据框如下所示:
time value treat
1 10 c
2 20 c
3 15 c
1 100 t1
2 210 t1
3 180 t1
1 110 t2
2 180 t2
3 140 t2
预期输出。相同,但 normvalue 列包含 c(1,1,1,10,10.5,12,11,9,9.333333)
我想使用 tidyverse 程序为每个治疗和时间点取出标准化的value 列...
【问题讨论】:
-
看看预期的输出应该是什么可能很有用。
-
比如,你只是想把时间点1的t1和t2除以10(时间点1的c组的值)等等?
-
@Atticus29 更新了更清晰的输入和预期的输出。