这个错误提示意味着,您正在尝试使用大小为6的逻辑向量作为行索引来子集数据框,但数据框中有56355行。这是不允许的,因为行索引必须与数据框的行数匹配。

要解决这个问题,您需要检查gene_meanthreshold的长度,并确保它们匹配。您可能需要使用length()函数来确定它们的长度,并使用rep()函数来重复threshold,使其与gene_mean的长度匹配。

例如,如果您有一个名为df的数据框,并且想要子集gene_mean大于等于threshold的行,您可以使用以下代码:

# 检查 gene_mean 和 threshold 的长度
length(gene_mean)
length(threshold)

# 重复 threshold,使其与 gene_mean 的长度匹配
threshold <- rep(threshold, length(gene_mean))

# 使用逻辑向量子集行
df_subset <- df[gene_mean >= threshold, ]
Cant subset rows with gene_mean = threshold✖ Logical subscript gene_mean = threshold must be size 1 or 56355 not 6Run rlanglast_trace to see where the error occurred怎么解决

原文地址: https://www.cveoy.top/t/topic/hcgx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录