meaning of combn error: Error in FUN(X[[i]], ...) : n < m in R
meaning of combn error: Error in FUN(X[[i]], ...) : n < m in R
正在尝试创建一对元素,但出现以下错误:
Error in FUN(X[[i]], ...) : n < m
错误出现在运行代码后:
rslt <- lapply(split(my$symbol, my$character), combn, 2, simplify = F)
这里my
是我的数据框,符号和字符是数据框的列。数据框包含 26,552 行。在这里我发布了我的一小部分数据。
my:
symbol character
BHMT Abruptio Placentae
BHMT Diabetes Mellitus, Type 2
BHMT Lymphoma, Non-Hodgkin
BHMT Neural Tube Defects
BID Carcinoma, Hepatocellular
BID Stomach Neoplasms
BIN1 Alzheimer Disease
BIN1 Myopathies, Structural, Congenital
BIN1 Myopathy, Centronuclear, Autosomal Recessive
BIRC5 Lung Neoplasms
BIRC5 Ovarian Neoplasms
BIRC5 Stomach Neoplasms
BIRC6 Neoplasms
BIRC7 Carcinoma, Renal Cell
BLK Arthritis, Rheumatoid
BLK Lupus Erythematosus, Systemic
BLK Maturity-onset diabetes of the young, type 11
感谢任何帮助。谢谢。
这是元素数量少于 'm' 的情况之一。一种选择是为小于 'm'
的 list
的 length
创建例外
lapply(split(my$symbol, my$character), function(x)
if(length(x)>1) {
combn(x, 2, simplify=FALSE)
}
else x)
正在尝试创建一对元素,但出现以下错误:
Error in FUN(X[[i]], ...) : n < m
错误出现在运行代码后:
rslt <- lapply(split(my$symbol, my$character), combn, 2, simplify = F)
这里my
是我的数据框,符号和字符是数据框的列。数据框包含 26,552 行。在这里我发布了我的一小部分数据。
my:
symbol character
BHMT Abruptio Placentae
BHMT Diabetes Mellitus, Type 2
BHMT Lymphoma, Non-Hodgkin
BHMT Neural Tube Defects
BID Carcinoma, Hepatocellular
BID Stomach Neoplasms
BIN1 Alzheimer Disease
BIN1 Myopathies, Structural, Congenital
BIN1 Myopathy, Centronuclear, Autosomal Recessive
BIRC5 Lung Neoplasms
BIRC5 Ovarian Neoplasms
BIRC5 Stomach Neoplasms
BIRC6 Neoplasms
BIRC7 Carcinoma, Renal Cell
BLK Arthritis, Rheumatoid
BLK Lupus Erythematosus, Systemic
BLK Maturity-onset diabetes of the young, type 11
感谢任何帮助。谢谢。
这是元素数量少于 'm' 的情况之一。一种选择是为小于 'm'
的list
的 length
创建例外
lapply(split(my$symbol, my$character), function(x)
if(length(x)>1) {
combn(x, 2, simplify=FALSE)
}
else x)