组合错误的含义:FUN(X [[i]],...)中的错误:n< R中的m [英] meaning of combn error: Error in FUN(X[[i]], ...) : n < m in R

查看:389
本文介绍了组合错误的含义:FUN(X [[i]],...)中的错误:n< R中的m的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试创建一对元素,但出现以下错误:

Trying to create a pair of element but get the following error:

Error in FUN(X[[i]], ...) : n < m

运行代码后出现错误:

rslt <- lapply(split(my$symbol, my$character), combn, 2, simplify = F)

此处my 是我的数据框,符号和字符是数据框的列.数据框包含26,552行.我在这里发布了我数据的一小部分.

Here my is my data frame and symbol and character is column of data frame. the data frame contain 26,552 rows. Here i posted the small part of my data.

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

任何帮助表示赞赏.谢谢.

Any help appreciated. Thank you.

推荐答案

这是元素数少于'm'的情况之一.一种选择是为listlength创建一个小于'm'的异常

This is one of the cases where there are less number of elements than 'm'. One option would be to create an exception for length of list that are less than 'm'

lapply(split(my$symbol, my$character), function(x)
          if(length(x)>1) {
            combn(x, 2, simplify=FALSE)
           }
           else x)

这篇关于组合错误的含义:FUN(X [[i]],...)中的错误:n&lt; R中的m的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆