简体   繁体   English

R 中的数据框/向量上下文

[英]Data frame/vector context in R

Not sure how to explain what I'm asking for, but here is an example of code:不知道如何解释我的要求,但这里有一个代码示例:

aat<-as.character(lapply(
    list.files(), 
    function(i) { 
        if(regexpr('new\\_mailed',i,ignore.case=T)>0) { 
            return(i); 
        } 
    }
))

basically, this will return NULL if the filename in the current iteration doesn't satisfy the regex.基本上,如果当前迭代中的文件名不满足正则表达式,这将返回NULL

what I want to do is do as.character(..all that code here..)[only get items where not equal to NULL] without having to assign to a variable and then do variable[variable != NULL]我想要做的是做as.character(..all that code here..)[only get items where not equal to NULL]而不必分配给变量然后做variable[variable != NULL]

is this possible?这可能吗?

解决方案是使用list.files(pattern = "new\\\\_mailed")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM