R 搜索一个有序的;列表“;匹配条件当没有任何内容与条件匹配时,列表长度=1

R 搜索一个有序的;列表“;匹配条件当没有任何内容与条件匹配时,列表长度=1,r,R,我有一个有3列的排序列表,我正在搜索第二列是否匹配2或4,然后返回第一列的元素(如果匹配),并将其放入函数中 noOutliers((L1LeanList[order(L1LeanList[,1]),])[(L1LeanList[order(L1LeanList[,1]),2]==2)| (L1LeanList[order(L1LeanList[,1]),2]==4),1]) 当没有符合条件时。我得

我有一个有3列的排序列表,我正在搜索第二列是否匹配2或4,然后返回第一列的元素(如果匹配),并将其放入函数中

noOutliers((L1LeanList[order(L1LeanList[,1]),])[(L1LeanList[order(L1LeanList[,1]),2]==2)|
                                                (L1LeanList[order(L1LeanList[,1]),2]==4),1])
当没有符合条件时。我得到一份工作

Error in ((L1LeanList[order(L1LeanList[, 1]), ])[1, ])[(L1LeanList[order(L1LeanList[,  : 
  incorrect number of dimensions
由于我们实际上拥有List[List[全部为假]]

我不能把L1LLSorted之类的东西分出来让我看看

foo <- bar[(bar[,2]==2 | bar[,2]==4),1]

foo请原谅我的迟钝,但我没有看到数据测试用例。我所看到的都是失败的尝试,都是成功的尝试。我正在寻找另一种工作尝试。由于这个原因,我的代码变得非常冗长,看起来非常糟糕。更糟糕的是,它可能效率低下。您能提供一些数据来运行代码吗?
noOutliers<-function(oList)
{
if (length(oList)<=20) return ("insufficient data")
cumSum<-0
iterCount<-0
for(i in round(length(oList)*3/10-.000001):round(length(oList)*7/10+.000001)+1)#adjustments deal with .5->even number rounding r mishandling
{                                                                              #and 1-based indexing (ex. for a list 1-10, taking 3-7 cuts off 1,2,8,9,10, imbalanced.)
  cumSum<-cumSum+oList[i]
  iterCount<-iterCount+1
}
return(cumSum/iterCount)
foo <- bar[(bar[,2]==2 | bar[,2]==4),1]