我在这里发布的问题与我两天前发布的关于 gompertz 老化分析的另一个问题密切相关。
我正在尝试构建一个生存对象,请参阅 R 中的 ?Surv。这将有望用于执行 Gompertz 分析以产生两个值的输出(有关详细信息,请参阅原始问题)。
我有来自苍蝇实验的生存数据,该实验检查了各种基因型的衰老率。这些数据以多种布局提供给我,因此您可以选择哪种布局,以最适合答案的为准。
一个数据框(wide.df)看起来像这样,其中每个基因型(Exp,其中有 ~640 个)都有一行,并且从第 4 天到第 98 天按顺序水平排列,每两天有新的死亡人数。
Exp Day4 Day6 Day8 Day10 Day12 Day14 ...
A 0 0 0 2 3 1 ...
我用这个做例子:
wide.df2<-data.frame("A",0,0,0,2,3,1,3,4,5,3,4,7,8,2,10,1,2)
colnames(wide.df2)<-c("Exp","Day4","Day6","Day8","Day10","Day12","Day14","Day16","Day18","Day20","Day22","Day24","Day26","Day28","Day30","Day32","Day34","Day36")
另一个版本是这样的,每天每个“Exp”都有一行,并记录当天的死亡人数。
Exp Deaths Day
A 0 4
A 0 6
A 0 8
A 2 10
A 3 12
.. .. ..
做这个例子:
df2<-data.frame(c("A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A","A"),c(0,0,0,2,3,1,3,4,5,3,4,7,8,2,10,1,2),c(4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36))
colnames(df2)<-c("Exp","Deaths","Day")
每个基因型中大约有 50 只苍蝇。我现在需要帮助的是如何从上述数据框之一转换为有效的生存对象。这个物体是什么样子的?我如何从上面顺利到达生存对象?