我想使用R软件上的MICE包对一组变量(生态特征)执行多种实现。
这是我的数据框的样子:
#Example of data frame (lines : species, columns: traits, values : traits value for each species)
tab_sptraits<- data.frame (
trait1 = c(15, 2, 3, 6, 5, NA, NA, 5, 4, 6, 17),
trait2 = c(511, 532, 426, NA, 236, NA, 653, NA, 569, 345, 568),
row.names = c("sp1", "sp2", "sp3", "sp4", "sp5", "sp6", "sp7", "sp8", "sp9", "sp10", "sp11")
)
tab_sptraits
对于每个物种(系)和每个系(列),都有(从生物学角度而言)最小值和最大值:
minmaxvalue_trait1<- data.frame (
min = c(5, 1, 1, 1, 1, 2, 1, 3, 3, 1, 4),
max = c(22, 12, 35, 8, 9, 11, 9, 10.5, 4.5, 6, 31),
row.names = c("sp1", "sp2", "sp3", "sp4", "sp5", "sp6", "sp7", "sp8", "sp9", "sp10", "sp11")
)
minmaxvalue_trait2 <- data.frame (
min = c(420, 231, 421, 129, 210, 785, 264, 265, 232, 126, 549),
max = c(652, 784, 569, 399, 358, 1365, 795, 396, 785, 647,981),
row.names = c("sp1", "sp2", "sp3", "sp4", "sp5", "sp6", "sp7", "sp8", "sp9", "sp10", "sp11")
)
minmaxvalue_trait2
因此,我想根据这些最小值和最大值为NA分配值: 例如,对于n°4物种(“ sp4”行),生物学特性2(“ trait2”列)的值应介于129和399之间。
我以前看过有关列约束(here)的文章,但是我没有发现关于行约束的信息(水平),甚至都没有!
是否可以应用这些限制?如果是这样,我应该如何进行?
谢谢您的帮助