尝试创建一对元素,但会收到以下错误:
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
任何帮助表示赞赏。谢谢。
答案 0 :(得分:4)
这是元素数量少于&#39; m&#39;的情况之一。一种选择是为length
list
创建一个小于&#39; m&#39;
lapply(split(my$symbol, my$character), function(x)
if(length(x)>1) {
combn(x, 2, simplify=FALSE)
}
else x)