r - 累积常设作物随时间变化公式
问题描述
这里的园艺博士生,从事一项涉及葡萄根动力学的研究。
我正在尝试计算三年内每次观察期间的运行累积根数(活根-死+新生)。我总共进行了 43 次观察。会话 2 到 43 是出生会话(新根诞生),会话 3 到 44 是一些根死亡或消失但我们仍然有活根的会话。
我在计算累积总和方面取得了一定的成功,但还没有开发出可以让我获得运行累积立项作物的代码。
这是我迄今为止开发的:
# make new dataframe
standingcrop <- all_roots %>%
select(BirthSession, roots, ComboDeadGone, Tube, Censored) %>%
filter(!is.na(roots)) %>%
arrange(BirthSession)
# calculate cumulative sum of roots by birthsession
standingcrop <- standingcrop %>%
group_by(BirthSession, Tube) %>%
mutate("standingcrop" = cumsum(roots))
#calculate cumulative difference - difference by deathsession
standingcrop2 <- all_roots %>%
select(BirthSession, roots, ComboDeadGone, Tube, Censored) %>%
filter(!is.na(roots)) %>%
arrange(ComboDeadGone)
standingcrop2 <- standingcrop2 %>%
group_by(BirthSession > 2, Tube) %>%
mutate("standingcrop" = cumulDiff(roots))
有没有人知道如何在每次观察期间获得累积的常设作物(在给定观察期间出生的根数 - 在该观察期间死亡或消失的根数?)?
太感谢了!
解决方案
推荐阅读
- python - Python Selenium Webdriver 表值到 Excel
- c# - 将 nvarchar 转换为 int 时 C# 转换失败
- laravel - 路由没有检测到ajax url
- javascript - Mongoose 检索对象数组。对于每个对象,我只想要两个属性
- c - 将 char 数组传递给另一个函数时,Realloc 返回无效指针
- java - 在 Spring Boot 中连接到多个“动态”数据库以及本地“静态”数据库
- javascript - javascript - 在 html 标签中包装选择(并打开它)
- ios - 如何让我的 UICollectionViewCell 阴影渗入我的主视图?
- javascript - 使用单个三元运算符渲染多个组件
- windows - Perl 串口访问 [Windows 10]